chore: routes/nojs.js

This commit is contained in:
Bobby Wibowo 2022-08-19 09:30:09 +07:00
parent 0d05da40b0
commit 19eac1d98a
No known key found for this signature in database
GPG Key ID: 51C3A1E1E22D26CF

View File

@ -5,10 +5,10 @@ const utils = require('./../controllers/utilsController')
const config = require('./../config')
routes.get('/nojs', async (req, res) => {
// TODO: Update res.render() to allow bypassing cache on demand,
// so that this GET route can instead re-use persistent cache
return res.render('nojs', {
config,
utils,
versions: utils.versionStrings
config, utils, versions: utils.versionStrings
})
})
@ -16,6 +16,8 @@ routes.get('/nojs', async (req, res) => {
// 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) => {
// Map built-in Response.json() function into Response.render() accordingly
// Since NoJS uploader needs to reply with a complete HTML page
res._json = res.json
res.json = (...args) => {
const result = args[0]