Newer
Older
Labyrinth / src / app.ts
import * as express from "express";
import { join } from "path";
import { FileStateRepository } from "./FileStateRepository";
import { GameServer, GameServerOptions } from "./GameServer";
import { CreateLabyrinthMiddleware } from "./LabyrinthMiddleware";
import { createSampleMaps } from "./SampleMaps";

// settings
const port = 8085;
const apiRoot = "/graphql";
const saveFile = "./repo.lgr";
const webRoot = "/";

const app = express();

const gameOptions = {
    mapRepo: { loadAllMaps: createSampleMaps },
    stateRepo: new FileStateRepository(saveFile),
} as GameServerOptions;
const games = new GameServer(gameOptions);
app.use(apiRoot, CreateLabyrinthMiddleware(true, games));

app.use(webRoot + "style", express.static(join(__dirname, "..", "style")));
app.use(webRoot, express.static(join(__dirname, "..", "public")));

app.listen(port, () => console.log(`App listening on port ${port}...`));