aboutsummaryrefslogtreecommitdiff
path: root/src/api/routes/albums/link/linksGET.js
blob: 4487c267ad8e9108ae5c83cb98d0f0a1bb078929 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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;