Added nanoexpress

This commit is contained in:
SamTV12345 2024-08-18 22:29:19 +02:00
parent 1e91efc16c
commit 3c66e8c5d6
5 changed files with 51 additions and 4 deletions

View file

@ -18,6 +18,7 @@ const settings = require('../utils/Settings');
const stats = require('../stats')
import util from 'util';
const webaccess = require('./express/webaccess');
import nanoexpress from 'nanoexpress';
import SecretRotator from '../security/SecretRotator';
@ -100,7 +101,7 @@ exports.createServer = async () => {
exports.restartServer = async () => {
await closeServer();
const app = express(); // New syntax for express v3
const app = nanoexpress(); // New syntax for express v3
if (settings.ssl) {
console.log('SSL -- enabled');

View file

@ -6,7 +6,7 @@ const padManager = require('../../db/PadManager');
exports.expressCreateServer = (hookName:string, args:ArgsExpressType, cb:Function) => {
// redirects browser to the pad's sanitized url if needed. otherwise, renders the html
args.app.param('pad', (req:any, res:any, next:Function, padId:string) => {
/*args.app.param('pad', (req:any, res:any, next:Function, padId:string) => {
(async () => {
// ensure the padname is valid and the url doesn't end with a /
if (!padManager.isValidPadId(padId) || /\/$/.test(req.url)) {
@ -27,6 +27,6 @@ exports.expressCreateServer = (hookName:string, args:ArgsExpressType, cb:Functio
res.status(302).send(`You should be redirected to <a href="${realURL}">${realURL}</a>`);
}
})().catch((err) => next(err || new Error(err)));
});
});*/
return cb();
};

View file

@ -34,7 +34,7 @@ exports.expressPreSession = async (hookName:string, {app}:any) => {
// Minify will serve static files compressed (minify enabled). It also has
// file-specific hacks for ace/require-kernel/etc.
app.all('/static/:filename(*)', minify);
app.get('/static/:filename(*)', minify);
// serve plugin definitions
// not very static, but served here so that client can do