api tags controller simplified: rm tags/slug route

This commit is contained in:
tmshv committed 2020-03-03 01:35:36 +03:00
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`
})
}
}
-1
View File
@@ -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}`)