From 20ab7f84abd07b744d0c73f0dd54879ff884e534 Mon Sep 17 00:00:00 2001
From: Carl Worth <cworth@cworth.org>
Date: Wed, 27 May 2020 10:06:23 -0700
Subject: [PATCH] Use an express Router for each of the game-engine-specific
 sub-apps

This eliminates the redundant code that was otherwise required by
using an entire app at the level of each game engine, (setting up
cors, body-parser, nunjucks configuration, etc.).

So this is much more pleasant, with less boilerplate and less code
duplication.
---
 empires.js   | 16 ++--------------
 tictactoe.js | 16 ++--------------
 2 files changed, 4 insertions(+), 28 deletions(-)

diff --git a/empires.js b/empires.js
index 034ba42..c2ba106 100644
--- a/empires.js
+++ b/empires.js
@@ -1,18 +1,6 @@
 const express = require("express");
-const cors = require("cors");
-const body_parser = require("body-parser");
-const path = require("path");
-const nunjucks = require("nunjucks");
-
-const app = express();
-app.use(cors());
-app.use(body_parser.urlencoded({ extended: false }));
-app.use(body_parser.json());
-
-nunjucks.configure("templates", {
-  autoescape: true,
-  express: app
-});
+
+const app = express.Router();
 
 const GameState = {
   JOIN:    1,
diff --git a/tictactoe.js b/tictactoe.js
index 82c5f7e..766c1e4 100644
--- a/tictactoe.js
+++ b/tictactoe.js
@@ -1,18 +1,6 @@
 const express = require("express");
-const cors = require("cors");
-const body_parser = require("body-parser");
-const path = require("path");
-const nunjucks = require("nunjucks");
-
-const app = express();
-app.use(cors());
-app.use(body_parser.urlencoded({ extended: false }));
-app.use(body_parser.json());
-
-nunjucks.configure("templates", {
-  autoescape: true,
-  express: app
-});
+
+const app = express.Router();
 
 class TicTacToe {
   constructor() {
-- 
2.45.2