filesafe/routes/nojs.js
Bobby Wibowo b75deb268f
Updated nojs.js
Forgot to add version strings.
2019-09-20 01:27:00 +07:00

30 lines
828 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,
versions: utils.versionStrings,
gitHash: utils.gitHash
})
})
routes.post('/nojs', (req, res, next) => {
res._json = res.json
res.json = (...args) => {
const result = args[0]
return res.render('nojs', {
config,
versions: utils.versionStrings,
gitHash: utils.gitHash,
errorMessage: result.success ? '' : (result.description || 'An unexpected error occurred.'),
files: result.files || [{}]
})
}
return uploadController.upload(req, res, next)
})
module.exports = routes