apply loki_middlewares when starting our own daemon

This commit is contained in:
Ryan Tharp 2021-03-03 04:15:36 +00:00
parent a49b5c5fa4
commit 9a9830471c
1 changed files with 8 additions and 0 deletions

View File

@ -9,6 +9,7 @@ const libsignal = require('libsignal');
const adnServerAPI = require('../server/fetchWrapper.js');
const loki_crypt = require('../lib.loki_crypt');
const config = require('../lib.config.js');
const loki_middlewares = require('../middlewares.js');
const ADN_SCOPES = 'basic stream write_post follow messages update_profile files export';
@ -100,10 +101,17 @@ const ensureUnifiedServer = () => {
//console.log(webbind + ':' + webport, 'free', free);
if (free) {
console.log('starting unified server');
// make sure we use the same config...
process.env['admin:modKey'] = 'JustMakingSureThisIsEnabled';
hasAdminAPI = true;
startPlatform = require('../server/app');
//
startPlatform.publicApp.use(loki_middlewares.snodeOnionMiddleware);
// Express 4.x specific
// position it to spot 2
startPlatform.publicApp._router.stack.splice(2, 0, startPlatform.publicApp._router.stack.splice(startPlatform.publicApp._router.stack.length - 1, 1)[0]);
weStartedUnifiedServer = true;
} else {
console.log('detected running unified server, testing that');