From 9eb087bf6d1238329c795145bd3bcf949ef5e763 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Tue, 3 Mar 2020 01:35:36 +0300 Subject: [PATCH] api tags controller simplified: rm tags/slug route --- modules/hudozka-api/src/controllers/tag.ts | 26 ---------------------- modules/hudozka-api/src/server.ts | 1 - 2 files changed, 27 deletions(-) diff --git a/modules/hudozka-api/src/controllers/tag.ts b/modules/hudozka-api/src/controllers/tag.ts index 4e5ca030..0185cbf8 100644 --- a/modules/hudozka-api/src/controllers/tag.ts +++ b/modules/hudozka-api/src/controllers/tag.ts @@ -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` - }) - } -} diff --git a/modules/hudozka-api/src/server.ts b/modules/hudozka-api/src/server.ts index 458a4bbe..21104af6 100644 --- a/modules/hudozka-api/src/server.ts +++ b/modules/hudozka-api/src/server.ts @@ -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}`)