on('uncaughtException', console.error)
.on('unhandledRejection', console.error);
const config = require(__dirname+'/lib/misc/config.js')
, express = require('express')
, path = require('path')
, app = express()
, server = require('http').createServer(app)
, cookieParser = require('cookie-parser')
, { port, cookieSecret, debugLogs, google, hcaptcha } = require(__dirname+'/configs/secrets.js')
, Mongo = require(__dirname+'/db/db.js')
, dynamicResponse = require(__dirname+'/lib/misc/dynamic.js')
, commit = require(__dirname+'/lib/misc/commit.js')
, { version } = require(__dirname+'/package.json')
, formatSize = require(__dirname+'/lib/converter/formatsize.js')
, CachePugTemplates = require('cache-pug-templates')
, Permissions = require(__dirname+'/lib/permission/permissions.js');
(async () => {
const env = process.env.NODE_ENV;
const production = env === 'production';
debugLogs && console.log('process.env.NODE_ENV =', env);
// connect to mongodb
debugLogs && console.log('CONNECTING TO MONGODB');
await Mongo.connect();
await Mongo.checkVersion();
await config.load();
// connect to redis
debugLogs && console.log('CONNECTING TO REDIS');
const redis = require(__dirname+'/lib/redis/redis.js');
// load roles early
const roleManager = require(__dirname+'/lib/permission/rolemanager.js');
await roleManager.load();
// disable useless express header
app.disable('x-powered-by');
//query strings
app.set('query parser', 'simple');
// parse forms
app.use(express.urlencoded({extended: false}));
// parse cookies
app.use(cookieParser(cookieSecret));
// session store
const sessionMiddleware = require(__dirname+'/lib/middleware/permission/usesession.js');
// connect socketio
const Socketio = require(__dirname+'/lib/misc/socketio.js');
debugLogs && console.log('STARTING WEBSOCKET');
Socketio.connect(server, sessionMiddleware);
t is not inherently vulnerable, but it is important to ensure that the secrets and configurations used in the script (such as the port, cookieSecret, google, and hcaptcha variables imported from configs/secrets.js)
Take that down fags