api tags controller simplified: rm tags/slug route
This commit is contained in:
1 parent
06745b45f4
commit
9eb087bf6d
2 files changed
-27
No files matched your search
@@ -20,29 +20,3 @@ export async function getAll(req: Request, res: Response) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export async function findItems(req: Request, res: Response) {
|
||||
const slug = req.params.slug
|
||||
|
||||
const data = await Page.find({
|
||||
tags: {
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
const tags = data
|
||||
.flatMap(x => x.tags)
|
||||
.filter(x => x.isValid())
|
||||
const items = unique(tags, t => t.slug)
|
||||
|
||||
if (data) {
|
||||
res.json({
|
||||
items,
|
||||
})
|
||||
} else {
|
||||
res.status(404)
|
||||
res.json({
|
||||
error: `Not found`
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,6 @@ async function main() {
|
||||
app.get('/image', image.getItem)
|
||||
|
||||
app.get('/tags', tag.getAll)
|
||||
app.get('/tags/:slug', tag.findItems)
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`> Ready on http://localhost:${port}`)
|
||||
|
||||
Reference in new issue
Block a user