X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=lmno.js;h=6651adfa692e60c401cb58d9cf4a5c5e951f4397;hb=f27cdf8b57b41a91dd7ab67be407d803dcaad1a3;hp=8d66b41ea09e066ffc2acce777a744c83f837c99;hpb=fbf331eedc7d4579ec861c140e26a11b04278c1c;p=lmno-server diff --git a/lmno.js b/lmno.js index 8d66b41..6651adf 100644 --- a/lmno.js +++ b/lmno.js @@ -247,9 +247,10 @@ app.get('/admin/', auth_admin, (request, response) => { /* Mount sub apps. only _after_ we have done all the middleware we need. */ for (let key in engines) { const engine = engines[key]; + const router = engine.Game.router; /* Add routes that are common to all games. */ - engine.router.get('/', (request, response) => { + router.get('/', (request, response) => { const game = request.game; if (! request.session.nickname) @@ -258,7 +259,7 @@ for (let key in engines) { response.render(`${game.meta.identifier}-game.html`); }); - engine.router.get('/events', (request, response) => { + router.get('/events', (request, response) => { const game = request.game; game.handle_events(request, response); @@ -267,7 +268,7 @@ for (let key in engines) { /* Further, add some routes conditionally depending on whether the * engine provides specific, necessary methods for the routes. */ if (engine.Game.prototype.add_move) { - engine.router.post('/move', (request, response) => { + router.post('/move', (request, response) => { const game = request.game; const move = request.body.move; @@ -285,7 +286,7 @@ for (let key in engines) { } /* And mount the whole router at the path for the game. */ - app.use(`/${engine.Game.meta.identifier}/[a-zA-Z0-9]{4}/`, engine.router); + app.use(`/${engine.Game.meta.identifier}/[a-zA-Z0-9]{4}/`, router); } app.listen(4000, function () {