From 19eac1d98a904de450968853ffbae8e03329e104 Mon Sep 17 00:00:00 2001 From: Bobby Wibowo Date: Fri, 19 Aug 2022 09:30:09 +0700 Subject: [PATCH] chore: routes/nojs.js --- routes/nojs.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/routes/nojs.js b/routes/nojs.js index cea0953..b4eafde 100644 --- a/routes/nojs.js +++ b/routes/nojs.js @@ -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]