workadventure/back/src/Controller/MapController.ts

30 lines
840 B
TypeScript
Raw Normal View History

import express from "express";
import {Application, Request, Response} from "express";
import {OK} from "http-status-codes";
import {URL_ROOM_STARTED} from "../Enum/EnvironmentVariable";
export class MapController {
App: Application;
constructor(App: Application) {
this.App = App;
this.getStartMap();
this.assetMaps();
}
assetMaps() {
this.App.use('/map/files', express.static('src/Assets/Maps'));
}
// Returns a map mapping map name to file name of the map
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;
res.status(OK).send({
2020-07-23 18:43:51 +02:00
mapUrlStart: url,
startInstance: "global"
});
});
}
}