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

const port = 8080;
const apiRoot = "/graphql";
const saveFile = "./repo.lgr";
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.listen(port, () => console.log(`App listening on port ${port}...`));