workadventure/back/src/Controller/MapController.ts
gparant 7f989cfd23 Add maps in back
- Add all map json in back
 - Create middleware to check authentification user
 - Create controllers to get map
 - Create access to get all files in folder Assets/Maps
2020-05-09 17:50:47 +02:00

35 lines
955 B
TypeScript

import express from "express";
import path from "path";
import {Application, Request, Response} from "express";
import {OK} from "http-status-codes";
const MapFloor0 = require('../Assets/Maps/Floor0/floor0.json');
const MapFloor1 = require('../Assets/Maps/Floor1/floor1.json');
export class MapController{
App : Application;
constructor(App : Application) {
this.App = App;
this.getFloor0();
this.getFloor1();
this.assetMaps();
}
assetMaps(){
this.App.use('/maps', express.static('src/Assets/Maps'));
}
//permit to login on application. Return token to connect on Websocket IO.
getFloor0(){
this.App.get("/floor0", (req: Request, res: Response) => {
return res.status(OK).send(MapFloor0);
});
}
getFloor1(){
this.App.get("/floor1", (req: Request, res: Response) => {
return res.status(OK).send(MapFloor1);
});
}
}