fix: routes/nojs

This commit is contained in:
Bobby Wibowo 2022-08-04 22:17:49 +07:00
parent 3e0aa1361d
commit abe27b746c
No known key found for this signature in database
GPG Key ID: 51C3A1E1E22D26CF

View File

@ -12,7 +12,10 @@ routes.get('/nojs', async (req, res) => {
})
})
routes.post('/nojs', async (req, res) => {
// HyperExpress defaults to 250kb
// https://github.com/kartikk221/hyper-express/blob/6.4.4/docs/Server.md#server-constructor-options
const maxBodyLength = parseInt(config.uploads.maxSize) * 1e6
routes.post('/nojs', { max_body_length: maxBodyLength }, async (req, res) => {
res._json = res.json
res.json = (...args) => {
const result = args[0]
@ -25,10 +28,6 @@ routes.post('/nojs', async (req, res) => {
})
}
return upload.upload(req, res)
}, {
// HyperExpress defaults to 250kb
// https://github.com/kartikk221/hyper-express/blob/6.2.4/docs/Server.md#server-constructor-options
max_body_length: parseInt(config.uploads.maxSize) * 1e6
})
module.exports = routes