feat: req content-type json -> application/json

This commit is contained in:
Bobby Wibowo 2022-07-25 06:12:55 +07:00
parent 4ca64b141f
commit 1b109e0dc0
No known key found for this signature in database
GPG Key ID: 51C3A1E1E22D26CF
5 changed files with 18 additions and 18 deletions

View File

@ -189,7 +189,7 @@ self.list = async (req, res) => {
} }
self.create = async (req, res) => { self.create = async (req, res) => {
utils.assertRequestType(req, 'json') utils.assertRequestType(req, 'application/json')
const user = await utils.authorize(req) const user = await utils.authorize(req)
// Parse POST body // Parse POST body
@ -234,7 +234,7 @@ self.create = async (req, res) => {
} }
self.delete = 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() // Parse POST body and re-map for .disable()
req.body = await req.json() req.body = await req.json()
@ -247,7 +247,7 @@ self.delete = async (req, res) => {
} }
self.disable = async (req, res) => { self.disable = async (req, res) => {
utils.assertRequestType(req, 'json') utils.assertRequestType(req, 'application/json')
const user = await utils.authorize(req) const user = await utils.authorize(req)
const ismoderator = perms.is(user, 'moderator') const ismoderator = perms.is(user, 'moderator')
@ -321,7 +321,7 @@ self.disable = async (req, res) => {
} }
self.edit = async (req, res) => { self.edit = async (req, res) => {
utils.assertRequestType(req, 'json') utils.assertRequestType(req, 'application/json')
const user = await utils.authorize(req) const user = await utils.authorize(req)
const ismoderator = perms.is(user, 'moderator') const ismoderator = perms.is(user, 'moderator')
@ -424,7 +424,7 @@ self.edit = async (req, res) => {
} }
self.rename = 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() // Parse POST body and re-map for .edit()
req.body = await req.json() req.body = await req.json()
@ -636,7 +636,7 @@ self.generateZip = async (req, res) => {
} }
self.addFiles = async (req, res) => { self.addFiles = async (req, res) => {
utils.assertRequestType(req, 'json') utils.assertRequestType(req, 'application/json')
const user = await utils.authorize(req) const user = await utils.authorize(req)
// Parse POST body // Parse POST body

View File

@ -31,7 +31,7 @@ const self = {
const saltRounds = 10 const saltRounds = 10
self.verify = async (req, res) => { self.verify = async (req, res) => {
utils.assertRequestType(req, 'json') utils.assertRequestType(req, 'application/json')
// Parse POST body // Parse POST body
req.body = await req.json() req.body = await req.json()
@ -65,7 +65,7 @@ self.verify = async (req, res) => {
} }
self.register = async (req, res) => { self.register = async (req, res) => {
utils.assertRequestType(req, 'json') utils.assertRequestType(req, 'application/json')
// Parse POST body // Parse POST body
req.body = await req.json() req.body = await req.json()
@ -117,7 +117,7 @@ self.register = async (req, res) => {
} }
self.changePassword = async (req, res) => { self.changePassword = async (req, res) => {
utils.assertRequestType(req, 'json') utils.assertRequestType(req, 'application/json')
const user = await utils.authorize(req) const user = await utils.authorize(req)
// Parse POST body // Parse POST body
@ -150,7 +150,7 @@ self.assertPermission = (user, target) => {
} }
self.createUser = async (req, res) => { self.createUser = async (req, res) => {
utils.assertRequestType(req, 'json') utils.assertRequestType(req, 'application/json')
const user = await utils.authorize(req) const user = await utils.authorize(req)
// Parse POST body // Parse POST body
@ -216,7 +216,7 @@ self.createUser = async (req, res) => {
} }
self.editUser = async (req, res) => { self.editUser = async (req, res) => {
utils.assertRequestType(req, 'json') utils.assertRequestType(req, 'application/json')
const user = await utils.authorize(req) const user = await utils.authorize(req)
// Parse POST body, if required // Parse POST body, if required
@ -273,7 +273,7 @@ self.editUser = async (req, res) => {
} }
self.disableUser = 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() // Parse POST body and re-map for .editUser()
req.body = await req.json() req.body = await req.json()
@ -288,7 +288,7 @@ self.disableUser = async (req, res) => {
} }
self.deleteUser = async (req, res) => { self.deleteUser = async (req, res) => {
utils.assertRequestType(req, 'json') utils.assertRequestType(req, 'application/json')
const user = await utils.authorize(req) const user = await utils.authorize(req)
// Parse POST body // Parse POST body

View File

@ -34,7 +34,7 @@ self.generateUniqueToken = async () => {
} }
self.verify = async (req, res) => { self.verify = async (req, res) => {
utils.assertRequestType(req, 'json') utils.assertRequestType(req, 'application/json')
// Parse POST body // Parse POST body
req.body = await req.json() req.body = await req.json()

View File

@ -625,7 +625,7 @@ self.actuallyUploadUrls = async (req, res, user, data = {}) => {
/** Chunk uploads */ /** Chunk uploads */
self.finishChunks = async (req, res) => { self.finishChunks = async (req, res) => {
utils.assertRequestType(req, 'json') utils.assertRequestType(req, 'application/json')
if (!chunkedUploads) { if (!chunkedUploads) {
throw new ClientError('Chunked upload is disabled.', { statusCode: 403 }) throw new ClientError('Chunked upload is disabled.', { statusCode: 403 })
@ -1049,7 +1049,7 @@ self.sendUploadResponse = async (req, res, user, result) => {
/** Delete uploads */ /** Delete uploads */
self.delete = async (req, res) => { self.delete = async (req, res) => {
utils.assertRequestType(req, 'json') utils.assertRequestType(req, 'application/json')
// Parse POST body and re-map for .bulkDelete() // Parse POST body and re-map for .bulkDelete()
// Original API used by lolisafe v3's frontend // Original API used by lolisafe v3's frontend
@ -1067,7 +1067,7 @@ self.delete = async (req, res) => {
} }
self.bulkDelete = async (req, res) => { self.bulkDelete = async (req, res) => {
utils.assertRequestType(req, 'json') utils.assertRequestType(req, 'application/json')
const user = await utils.authorize(req) const user = await utils.authorize(req)
// Parse POST body, if required // Parse POST body, if required

View File

@ -375,7 +375,7 @@ self.stripIndents = string => {
self.assertRequestType = (req, type) => { self.assertRequestType = (req, type) => {
if (!req.is(type)) { if (!req.is(type)) {
throw new ClientError(`Request type must be ${type.toUpperCase()}.`) throw new ClientError(`Request Content-Type must be ${type}.`)
} }
} }