mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-13 16:06:21 +00:00
b117fa9ad1
also fix nunjucks templates not adhering to env vars overrides for domains config options, because they attempted to read config directly
30 lines
794 B
JavaScript
30 lines
794 B
JavaScript
const routes = require('express').Router()
|
|
const uploadController = require('./../controllers/uploadController')
|
|
const utils = require('./../controllers/utilsController')
|
|
const config = require('./../config')
|
|
|
|
routes.get('/nojs', async (req, res, next) => {
|
|
return res.render('nojs', {
|
|
config,
|
|
utils,
|
|
versions: utils.versionStrings
|
|
})
|
|
})
|
|
|
|
routes.post('/nojs', (req, res, next) => {
|
|
res._json = res.json
|
|
res.json = (...args) => {
|
|
const result = args[0]
|
|
return res.render('nojs', {
|
|
config,
|
|
utils,
|
|
versions: utils.versionStrings,
|
|
errorMessage: result.success ? '' : (result.description || 'An unexpected error occurred.'),
|
|
files: result.files || [{}]
|
|
})
|
|
}
|
|
return uploadController.upload(req, res, next)
|
|
})
|
|
|
|
module.exports = routes
|