]> git.cworth.org Git - empires-server/blobdiff - empires.js
Rename the /stats page to /admin
[empires-server] / empires.js
index 20dfa78d2102e6e1fe0d3b77bc23eb6cba729b30..69fc7c233a64c146b40cff97bb6826cb3e01be29 100644 (file)
@@ -1,9 +1,12 @@
 const express = require("express");
 const cors = require("cors");
 const body_parser = require("body-parser");
+const path = require("path");
 
 const app = express();
 app.use(cors());
+app.use(body_parser.urlencoded({ extended: false }));
+app.use(body_parser.json());
 
 const GameState = {
   JOIN:    1,
@@ -207,9 +210,6 @@ class Game {
   }
 }
 
-app.use(body_parser.urlencoded({ extended: false }));
-app.use(body_parser.json());
-
 function handle_events(request, response) {
   const game = request.game;
   /* These headers will keep the connection open so we can stream events. */
@@ -249,6 +249,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);