blob: 904687f4050ff04563745b4a083dccaf7d502399 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
const Route = require('../../../structures/Route');
const { dump } = require('dumper.js');
class linkDELETE extends Route {
constructor() {
super('/album/link/delete/:identifier', 'delete');
}
async run(req, res, db, user) {
const { identifier } = req.params;
if (!identifier) return res.status(400).json({ message: 'Invalid identifier supplied' });
try {
const link = await db.table('links')
.where({ identifier, userId: user.id })
.first();
dump(link);
if (!link) return res.status(400).json({ message: 'Identifier doesn\'t exist' });
await db.table('links')
.where({ id: link.id })
.delete();
await db.table('albumsLinks')
.where({ linkId: link.id })
.delete();
} catch (error) {
return super.error(res, error);
}
return res.json({
message: 'Successfully deleted link'
});
}
}
module.exports = linkDELETE;
|