blob: f1a3a26f6d9c4794b9866c595b8e9cb7dafea647 (
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
|
const Route = require('../../structures/Route');
const Util = require('../../utils/Util');
class filesGET extends Route {
constructor() {
super('/files', 'get');
}
async run(req, res, db, user) {
// Get all the files from the user
const files = await db.table('files')
.where('userId', user.id)
.orderBy('id', 'desc');
// For each file, create the public link to be able to display the file
for (let file of files) {
file = Util.constructFilePublicLink(file);
}
return res.json({
message: 'Successfully retrieved files',
files
});
}
}
module.exports = filesGET;
|