mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-14 16:36:21 +00:00
02e2e402c3
As the title says, this commit is a massive overhaul. I've rewritten/restrucuted almost everything in the controller scripts. Because of that, there's a considerable possibility that I've broken something somewhere. Notable changes: Added temporary uploads. Removed file name length changer from dashboard, in favor of an equivalent in homepage config tab. This allows non-registered users to also set file name length. A bunch of other undocmented stuff. I don't know, I'm too tired to remember them all.
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
const config = require('./../config')
|
|
const routes = require('express').Router()
|
|
const uploadController = require('./../controllers/uploadController')
|
|
const utils = require('./../controllers/utilsController')
|
|
|
|
const renderOptions = {
|
|
uploadDisabled: false,
|
|
maxFileSize: config.cloudflare.noJsMaxSize || config.uploads.maxSize
|
|
}
|
|
|
|
if (config.private)
|
|
if (config.enableUserAccounts) {
|
|
renderOptions.uploadDisabled = 'Anonymous upload is disabled.'
|
|
} else {
|
|
renderOptions.uploadDisabled = 'Running in private mode.'
|
|
}
|
|
|
|
routes.get('/nojs', async (req, res, next) => {
|
|
const options = { renderOptions }
|
|
options.gitHash = utils.gitHash
|
|
|
|
return res.render('nojs', options)
|
|
})
|
|
|
|
routes.post('/nojs', (req, res, next) => {
|
|
res._json = res.json
|
|
res.json = (...args) => {
|
|
const result = args[0]
|
|
|
|
const options = { renderOptions }
|
|
options.gitHash = utils.utils
|
|
|
|
options.errorMessage = result.success ? '' : (result.description || 'An unexpected error occurred.')
|
|
options.files = result.files || [{}]
|
|
|
|
return res.render('nojs', options)
|
|
}
|
|
|
|
return uploadController.upload(req, res, next)
|
|
})
|
|
|
|
module.exports = routes
|