2020-08-17 07:51:58 +02:00
|
|
|
const path = require('path')
|
|
|
|
|
2019-12-30 07:16:02 +01:00
|
|
|
if (process.env['config-file-path'] === undefined) {
|
2020-08-17 07:51:58 +02:00
|
|
|
process.env['config-file-path'] = path.join(__dirname, 'config.json');
|
2019-09-10 06:01:52 +02:00
|
|
|
}
|
2020-08-17 07:35:21 +02:00
|
|
|
const loki_middlewares = require('./middlewares.js');
|
|
|
|
const platform_middlewares = require('./server/middlewares.js');
|
|
|
|
const apps = require('./server/app.js');
|
2020-06-25 04:09:23 +02:00
|
|
|
|
2020-08-17 07:51:58 +02:00
|
|
|
const enableDebug = !!process.env['DEBUG']
|
2020-08-17 07:35:21 +02:00
|
|
|
if (enableDebug) {
|
|
|
|
apps.publicApp.use(platform_middlewares.debugMiddleware);
|
|
|
|
// Express 4.x specific
|
|
|
|
// position it to spot 2
|
|
|
|
apps.publicApp._router.stack.splice(2, 0, apps.publicApp._router.stack.splice(apps.publicApp._router.stack.length - 1, 1)[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
apps.publicApp.use(loki_middlewares.snodeOnionMiddleware);
|
2020-06-25 04:09:23 +02:00
|
|
|
// Express 4.x specific
|
|
|
|
// position it to spot 2
|
|
|
|
apps.publicApp._router.stack.splice(2, 0, apps.publicApp._router.stack.splice(apps.publicApp._router.stack.length - 1, 1)[0]);
|