diff options
| author | Pitu <[email protected]> | 2020-06-25 01:35:52 +0900 |
|---|---|---|
| committer | Pitu <[email protected]> | 2020-06-25 01:35:52 +0900 |
| commit | b526d8803696161961ffb9eb912cb4b83a3c9eff (patch) | |
| tree | bad1cef433bfbafb41ecb4849a8fd46c12f60dbd /src/api/routes/albums/link | |
| parent | Fix frontend registration display (diff) | |
| download | host.fuwn.me-b526d8803696161961ffb9eb912cb4b83a3c9eff.tar.xz host.fuwn.me-b526d8803696161961ffb9eb912cb4b83a3c9eff.zip | |
Optimize the queries fetching albums/files
Diffstat (limited to 'src/api/routes/albums/link')
| -rw-r--r-- | src/api/routes/albums/link/linksGET.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/api/routes/albums/link/linksGET.js b/src/api/routes/albums/link/linksGET.js new file mode 100644 index 0000000..edab49a --- /dev/null +++ b/src/api/routes/albums/link/linksGET.js @@ -0,0 +1,22 @@ +const Route = require('../../../structures/Route'); + +class linkPOST extends Route { + constructor() { + super('/album/:id/links', 'get'); + } + + async run(req, res, db, user) { + const { id } = req.params; + if (!id) return res.status(400).json({ message: 'Invalid id supplied' }); + + const links = await db.table('links') + .where({ albumId: id, userId: user.id }); + + return res.json({ + message: 'Successfully retrieved links', + links + }); + } +} + +module.exports = linkPOST; |