diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/api/routes/files/tagAddBatchPOST.js | 6 | ||||
| -rw-r--r-- | src/api/routes/files/tagAddPOST.js | 2 | ||||
| -rw-r--r-- | src/api/routes/tags/tagDELETE.js | 2 | ||||
| -rw-r--r-- | src/api/routes/tags/tagPOST.js | 10 | ||||
| -rw-r--r-- | src/api/utils/Log.js | 10 |
5 files changed, 17 insertions, 13 deletions
diff --git a/src/api/routes/files/tagAddBatchPOST.js b/src/api/routes/files/tagAddBatchPOST.js index 67b1b46..5091a81 100644 --- a/src/api/routes/files/tagAddBatchPOST.js +++ b/src/api/routes/files/tagAddBatchPOST.js @@ -1,6 +1,6 @@ const Route = require('../../structures/Route'); -class tagAddPOST extends Route { +class tagAddBatchPOST extends Route { constructor() { super('/file/tag/addBatch', 'post'); } @@ -30,11 +30,11 @@ class tagAddPOST extends Route { return res.json({ message: 'Successfully added tags to file', - data: addedTags, + data: { fileId, tags: addedTags }, errors, }); // eslint-disable-next-line consistent-return } } -module.exports = tagAddPOST; +module.exports = tagAddBatchPOST; diff --git a/src/api/routes/files/tagAddPOST.js b/src/api/routes/files/tagAddPOST.js index 3434f24..654dceb 100644 --- a/src/api/routes/files/tagAddPOST.js +++ b/src/api/routes/files/tagAddPOST.js @@ -27,7 +27,7 @@ class tagAddPOST extends Route { return res.json({ message: 'Successfully added tag to file', - data: tagName, + data: { fileId, tag }, }); // eslint-disable-next-line consistent-return } diff --git a/src/api/routes/tags/tagDELETE.js b/src/api/routes/tags/tagDELETE.js index c03ca64..cf74029 100644 --- a/src/api/routes/tags/tagDELETE.js +++ b/src/api/routes/tags/tagDELETE.js @@ -27,7 +27,7 @@ class tagDELETE extends Route { Delete the tag */ await db.table('tags').where({ id }).delete(); - return res.json({ message: 'The tag was deleted successfully' }); + return res.json({ message: 'The tag was deleted successfully', data: tag }); } catch (error) { return super.error(res, error); } diff --git a/src/api/routes/tags/tagPOST.js b/src/api/routes/tags/tagPOST.js index 856e0d4..5038b91 100644 --- a/src/api/routes/tags/tagPOST.js +++ b/src/api/routes/tags/tagPOST.js @@ -18,14 +18,18 @@ class tagPOST extends Route { if (tag) return res.status(401).json({ message: 'There\'s already a tag with that name' }); const now = moment.utc().toDate(); - await db.table('tags').insert({ + const insertObj = { name, userId: user.id, createdAt: now, editedAt: now, - }); + }; - return res.json({ message: 'The tag was created successfully' }); + const dbRes = await db.table('tags').insert(insertObj); + + insertObj.id = dbRes.pop(); + + return res.json({ message: 'The tag was created successfully', data: insertObj }); } } diff --git a/src/api/utils/Log.js b/src/api/utils/Log.js index 99d11e4..9a5efc9 100644 --- a/src/api/utils/Log.js +++ b/src/api/utils/Log.js @@ -3,27 +3,27 @@ const { dump } = require('dumper.js'); class Log { static info(args) { - if (this.checkIfArrayOrObject(args)) dump(args); + if (Log.checkIfArrayOrObject(args)) dump(args); else console.log(args); // eslint-disable-line no-console } static success(args) { - if (this.checkIfArrayOrObject(args)) dump(args); + if (Log.checkIfArrayOrObject(args)) dump(args); else console.log(chalk.green(args)); // eslint-disable-line no-console } static warn(args) { - if (this.checkIfArrayOrObject(args)) dump(args); + if (Log.checkIfArrayOrObject(args)) dump(args); else console.log(chalk.yellow(args)); // eslint-disable-line no-console } static error(args) { - if (this.checkIfArrayOrObject(args)) dump(args); + if (Log.checkIfArrayOrObject(args)) dump(args); else console.log(chalk.red(args)); // eslint-disable-line no-console } static debug(args) { - if (this.checkIfArrayOrObject(args)) dump(args); + if (Log.checkIfArrayOrObject(args)) dump(args); else console.log(chalk.gray(args)); // eslint-disable-line no-console } |