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 18:34:55 +02:00
|
|
|
import {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-24 22:53:10 +02:00
|
|
|
this.getStartMap();
|
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-24 22:53:10 +02:00
|
|
|
getStartMap() {
|
|
|
|
this.App.get("/start-map", (req: Request, res: Response) => {
|
2020-07-23 18:47:28 +02:00
|
|
|
const url = req.headers.host?.replace('api.', 'maps.') + URL_ROOM_STARTED;
|
2020-06-09 11:49:23 +02:00
|
|
|
res.status(OK).send({
|
2020-07-23 18:43:51 +02:00
|
|
|
mapUrlStart: url,
|
2020-05-23 17:27:49 +02:00
|
|
|
startInstance: "global"
|
2020-05-09 19:41:21 +02:00
|
|
|
});
|
2020-05-09 17:50:47 +02:00
|
|
|
});
|
|
|
|
}
|
2020-05-10 14:48:34 +02:00
|
|
|
}
|