From 1b109e0dc08efd060c11117bfd00b139d9498ffa Mon Sep 17 00:00:00 2001 From: Bobby Wibowo Date: Mon, 25 Jul 2022 06:12:55 +0700 Subject: [PATCH] feat: req content-type json -> application/json --- controllers/albumsController.js | 12 ++++++------ controllers/authController.js | 14 +++++++------- controllers/tokenController.js | 2 +- controllers/uploadController.js | 6 +++--- controllers/utilsController.js | 2 +- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/controllers/albumsController.js b/controllers/albumsController.js index 9fe7fd0..c8c9d29 100644 --- a/controllers/albumsController.js +++ b/controllers/albumsController.js @@ -189,7 +189,7 @@ self.list = async (req, res) => { } self.create = async (req, res) => { - utils.assertRequestType(req, 'json') + utils.assertRequestType(req, 'application/json') const user = await utils.authorize(req) // Parse POST body @@ -234,7 +234,7 @@ self.create = async (req, res) => { } self.delete = async (req, res) => { - utils.assertRequestType(req, 'json') + utils.assertRequestType(req, 'application/json') // Parse POST body and re-map for .disable() req.body = await req.json() @@ -247,7 +247,7 @@ self.delete = async (req, res) => { } self.disable = async (req, res) => { - utils.assertRequestType(req, 'json') + utils.assertRequestType(req, 'application/json') const user = await utils.authorize(req) const ismoderator = perms.is(user, 'moderator') @@ -321,7 +321,7 @@ self.disable = async (req, res) => { } self.edit = async (req, res) => { - utils.assertRequestType(req, 'json') + utils.assertRequestType(req, 'application/json') const user = await utils.authorize(req) const ismoderator = perms.is(user, 'moderator') @@ -424,7 +424,7 @@ self.edit = async (req, res) => { } self.rename = async (req, res) => { - utils.assertRequestType(req, 'json') + utils.assertRequestType(req, 'application/json') // Parse POST body and re-map for .edit() req.body = await req.json() @@ -636,7 +636,7 @@ self.generateZip = async (req, res) => { } self.addFiles = async (req, res) => { - utils.assertRequestType(req, 'json') + utils.assertRequestType(req, 'application/json') const user = await utils.authorize(req) // Parse POST body diff --git a/controllers/authController.js b/controllers/authController.js index 9afbb06..a3028c2 100644 --- a/controllers/authController.js +++ b/controllers/authController.js @@ -31,7 +31,7 @@ const self = { const saltRounds = 10 self.verify = async (req, res) => { - utils.assertRequestType(req, 'json') + utils.assertRequestType(req, 'application/json') // Parse POST body req.body = await req.json() @@ -65,7 +65,7 @@ self.verify = async (req, res) => { } self.register = async (req, res) => { - utils.assertRequestType(req, 'json') + utils.assertRequestType(req, 'application/json') // Parse POST body req.body = await req.json() @@ -117,7 +117,7 @@ self.register = async (req, res) => { } self.changePassword = async (req, res) => { - utils.assertRequestType(req, 'json') + utils.assertRequestType(req, 'application/json') const user = await utils.authorize(req) // Parse POST body @@ -150,7 +150,7 @@ self.assertPermission = (user, target) => { } self.createUser = async (req, res) => { - utils.assertRequestType(req, 'json') + utils.assertRequestType(req, 'application/json') const user = await utils.authorize(req) // Parse POST body @@ -216,7 +216,7 @@ self.createUser = async (req, res) => { } self.editUser = async (req, res) => { - utils.assertRequestType(req, 'json') + utils.assertRequestType(req, 'application/json') const user = await utils.authorize(req) // Parse POST body, if required @@ -273,7 +273,7 @@ self.editUser = async (req, res) => { } self.disableUser = async (req, res) => { - utils.assertRequestType(req, 'json') + utils.assertRequestType(req, 'application/json') // Parse POST body and re-map for .editUser() req.body = await req.json() @@ -288,7 +288,7 @@ self.disableUser = async (req, res) => { } self.deleteUser = async (req, res) => { - utils.assertRequestType(req, 'json') + utils.assertRequestType(req, 'application/json') const user = await utils.authorize(req) // Parse POST body diff --git a/controllers/tokenController.js b/controllers/tokenController.js index 0ecaf14..e82c667 100644 --- a/controllers/tokenController.js +++ b/controllers/tokenController.js @@ -34,7 +34,7 @@ self.generateUniqueToken = async () => { } self.verify = async (req, res) => { - utils.assertRequestType(req, 'json') + utils.assertRequestType(req, 'application/json') // Parse POST body req.body = await req.json() diff --git a/controllers/uploadController.js b/controllers/uploadController.js index 04d3e78..4e14f40 100644 --- a/controllers/uploadController.js +++ b/controllers/uploadController.js @@ -625,7 +625,7 @@ self.actuallyUploadUrls = async (req, res, user, data = {}) => { /** Chunk uploads */ self.finishChunks = async (req, res) => { - utils.assertRequestType(req, 'json') + utils.assertRequestType(req, 'application/json') if (!chunkedUploads) { throw new ClientError('Chunked upload is disabled.', { statusCode: 403 }) @@ -1049,7 +1049,7 @@ self.sendUploadResponse = async (req, res, user, result) => { /** Delete uploads */ self.delete = async (req, res) => { - utils.assertRequestType(req, 'json') + utils.assertRequestType(req, 'application/json') // Parse POST body and re-map for .bulkDelete() // Original API used by lolisafe v3's frontend @@ -1067,7 +1067,7 @@ self.delete = async (req, res) => { } self.bulkDelete = async (req, res) => { - utils.assertRequestType(req, 'json') + utils.assertRequestType(req, 'application/json') const user = await utils.authorize(req) // Parse POST body, if required diff --git a/controllers/utilsController.js b/controllers/utilsController.js index 52236a9..670d1be 100644 --- a/controllers/utilsController.js +++ b/controllers/utilsController.js @@ -375,7 +375,7 @@ self.stripIndents = string => { self.assertRequestType = (req, type) => { if (!req.is(type)) { - throw new ClientError(`Request type must be ${type.toUpperCase()}.`) + throw new ClientError(`Request Content-Type must be ${type}.`) } }