+const express = require("express");
+const cors = require("cors");
+const body_parser = require("body-parser");
+
+const app = express();
+app.use(cors());
+
+class LMNO {
+ constructor() {
+ this.ids = {};
+ }
+
+ generate_id() {
+ return [null,null,null,null].map(() => LMNO.letters.charAt(Math.floor(Math.random() * LMNO.letters.length))).join('');
+ }
+
+ create_game(engine) {
+ do {
+ var id = this.generate_id();
+ } while (id in this.ids);
+
+ const game = {
+ id: id,
+ engine: engine,
+ };
+
+ this.ids[id] = game;
+
+ return game;
+ }
+}
+
+/* Some letters we don't use in our IDs:
+ *
+ * 1. Vowels (AEIOU) to avoid accidentally spelling an unfortunate word
+ * 2. Lowercase letters (replace with corresponding capital on input)
+ * 3. N (replace with M on input)
+ * 4. P (replace with B on input)
+ * 5. S (replace with F on input)
+ */
+LMNO.letters = "BCDFGHJKLMQRTVWXYZ";
+
+const lmno = new LMNO();
+
+app.post('/new/:game_engine', (request, response) => {
+ const game_engine = request.params.game_engine;
+ const game = lmno.create_game(game_engine);
+ response.send(JSON.stringify(game.id));
+});
+
+app.listen(4000, function () {
+ console.log('LMNO server listening on localhost:4000');
+});