]> git.cworth.org Git - lmno-server/blobdiff - lmno.js
Add simple session tracking
[lmno-server] / lmno.js
diff --git a/lmno.js b/lmno.js
index 64a106bf9a492f0475c5e6a9800a306b0c5bfcdb..fbef78f208a7decfd46300b094c29ce554b22515 100644 (file)
--- a/lmno.js
+++ b/lmno.js
@@ -1,9 +1,35 @@
 const express = require("express");
 const cors = require("cors");
 const body_parser = require("body-parser");
+const session = require("express-session");
+
+try {
+  var lmno_config = require("./lmno-config.json");
+} catch (err) {
+  config_usage();
+  process.exit(1);
+}
+
+function config_usage() {
+  console.log(`Error: Refusing to run without configuration.
+
+Please create a file named lmno-config.json that looks as follows:
+
+{
+  "session_secret": "<this should be a long string of true-random characters>";
+}
+
+Note: Don't use the exact text above, but instead replace the string
+with what it describes: a long string of random characters.`);
+}
 
 const app = express();
 app.use(cors());
+app.use(session({
+  secret: lmno_config.session_secret,
+  resave: false,
+  saveUninitialized: false
+}));
 
 /* Load each of our game mini-apps. */
 var empires = require("./empires");