diff --git a/dtp-base.js b/dtp-base.js index ae359bb..2c0d5eb 100644 --- a/dtp-base.js +++ b/dtp-base.js @@ -171,9 +171,7 @@ class SiteWebApp extends SiteRuntime { this.app.use( (req, res, next) => { - res.locals.dtp = { - request: req, - }; + res.locals.dtp = { request: req }; return next(); }, sessionService.middleware(), @@ -200,15 +198,7 @@ class SiteWebApp extends SiteRuntime { */ this.httpServer = http.createServer(this.app); - - /* - * Create Socket.io server bound to HTTP server - */ - - const { SiteIoServer } = await import('./lib/site-ioserver.js'); - this.log.info('creating Socket.io server'); - this.io = new SiteIoServer(this); - await this.io.start(this.httpServer); + this.createIoServer(); /* * Start the HTTP server @@ -230,6 +220,16 @@ class SiteWebApp extends SiteRuntime { }); } + async createIoServer ( ) { + /* + * Create Socket.io server bound to HTTP server + */ + const { SiteIoServer } = await import('./lib/site-ioserver.js'); + this.log.info('creating Socket.io server'); + this.io = new SiteIoServer(this); + await this.io.start(this.httpServer); + } + async loadControllers ( ) { const basePath = path.join(this.config.root, 'app', 'controllers'); const entries = await fs.promises.readdir(basePath, { withFileTypes: true });