2020-05-09 17:50:47 +02:00
|
|
|
import {OK} from "http-status-codes";
|
2020-05-10 18:34:55 +02:00
|
|
|
import {URL_ROOM_STARTED} from "../Enum/EnvironmentVariable";
|
2020-09-28 18:52:54 +02:00
|
|
|
import {HttpRequest, HttpResponse, TemplatedApp} from "uWebSockets.js";
|
|
|
|
import {BaseController} from "./BaseController";
|
2020-05-09 17:50:47 +02:00
|
|
|
|
2020-09-28 15:02:37 +02:00
|
|
|
//todo: delete this
|
2020-09-28 18:52:54 +02:00
|
|
|
export class MapController extends BaseController{
|
2020-05-09 17:50:47 +02:00
|
|
|
|
2020-09-28 18:52:54 +02:00
|
|
|
constructor(private App : TemplatedApp) {
|
|
|
|
super();
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
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() {
|
2020-09-28 18:52:54 +02:00
|
|
|
this.App.options("/start-map", (res: HttpResponse, req: HttpRequest) => {
|
|
|
|
this.addCorsHeaders(res);
|
|
|
|
|
|
|
|
res.end();
|
|
|
|
});
|
|
|
|
|
|
|
|
this.App.get("/start-map", (res: HttpResponse, req: HttpRequest) => {
|
|
|
|
this.addCorsHeaders(res);
|
|
|
|
|
|
|
|
const url = req.getHeader('host').replace('api.', 'maps.') + URL_ROOM_STARTED;
|
|
|
|
res.writeStatus("200 OK").end(JSON.stringify({
|
2020-07-23 18:43:51 +02:00
|
|
|
mapUrlStart: url,
|
2020-05-23 17:27:49 +02:00
|
|
|
startInstance: "global"
|
2020-09-28 18:52:54 +02:00
|
|
|
}));
|
2020-05-09 17:50:47 +02:00
|
|
|
});
|
|
|
|
}
|
2020-05-10 14:48:34 +02:00
|
|
|
}
|