2020-05-09 17:50:47 +02:00
|
|
|
import express from "express";
|
|
|
|
import {Application, Request, Response} from "express";
|
|
|
|
import {OK} from "http-status-codes";
|
2020-05-10 13:58:32 +02:00
|
|
|
import {ROOM_STARTED, ROOMS, URL_ROOM_STARTED} from "../Enum/EnvironmentVariable";
|
2020-05-09 17:50:47 +02:00
|
|
|
|
2020-05-09 19:41:21 +02:00
|
|
|
export class MapController {
|
|
|
|
App: Application;
|
2020-05-09 17:50:47 +02:00
|
|
|
|
2020-05-09 19:41:21 +02:00
|
|
|
constructor(App: Application) {
|
2020-05-09 17:50:47 +02:00
|
|
|
this.App = App;
|
2020-05-10 17:31:27 +02:00
|
|
|
this.getMaps();
|
2020-05-09 17:50:47 +02:00
|
|
|
this.assetMaps();
|
|
|
|
}
|
|
|
|
|
2020-05-09 19:41:21 +02:00
|
|
|
assetMaps() {
|
|
|
|
this.App.use('/map/files', express.static('src/Assets/Maps'));
|
2020-05-09 17:50:47 +02:00
|
|
|
}
|
|
|
|
|
2020-05-10 14:48:34 +02:00
|
|
|
// Returns a map mapping map name to file name of the map
|
2020-05-10 14:48:58 +02:00
|
|
|
getMaps() {
|
2020-05-09 19:41:21 +02:00
|
|
|
this.App.get("/maps", (req: Request, res: Response) => {
|
|
|
|
return res.status(OK).send({
|
2020-05-10 13:58:32 +02:00
|
|
|
mapStart: {key: ROOM_STARTED, url: URL_ROOM_STARTED},
|
|
|
|
maps: ROOMS
|
2020-05-09 19:41:21 +02:00
|
|
|
});
|
2020-05-09 17:50:47 +02:00
|
|
|
});
|
|
|
|
}
|
2020-05-10 14:48:34 +02:00
|
|
|
}
|