]> git.cworth.org Git - empires-server/commitdiff
empires: Serve the actual game file from the root of the app
authorCarl Worth <cworth@cworth.org>
Sun, 17 May 2020 21:45:34 +0000 (14:45 -0700)
committerCarl Worth <cworth@cworth.org>
Sun, 17 May 2020 22:36:18 +0000 (15:36 -0700)
This game.html file is actually totally static, but it lives at a
dynamic path (which includes the game ID in the path), so within the
dynamic app we need to serve the static file. To arrange for this we
symlink to the static file. Note that we're not committing the symlink
to git since the destination location can differ on each system.

.gitignore
empires.js

index 3c3629e647f5ddf82548912e337bea9826b434af..fa6e5f228430035236849b089b43a204cf60f79b 100644 (file)
@@ -1 +1,2 @@
 node_modules
+game.html
index 20dfa78d2102e6e1fe0d3b77bc23eb6cba729b30..593598ad6153c5c524fd2dfeaf7274f07cc36b63 100644 (file)
@@ -1,6 +1,7 @@
 const express = require("express");
 const cors = require("cors");
 const body_parser = require("body-parser");
+const path = require("path");
 
 const app = express();
 app.use(cors());
@@ -249,6 +250,10 @@ function handle_events(request, response) {
   });
 }
 
+app.get('/', (request, response) => {
+  response.sendFile(path.join(__dirname, './game.html'));
+});
+
 app.post('/register', (request, response) => {
   const game = request.game;
   game.add_player(request.body.name, request.body.character);