Adding a /map route and removing /start-map

This commit is contained in:
David Négrier 2020-10-13 15:29:08 +02:00
parent ac86914d82
commit 94538bfaf4
2 changed files with 13 additions and 4 deletions

View File

@ -26,6 +26,10 @@ export class MapController extends BaseController{
this.App.get("/map", (res: HttpResponse, req: HttpRequest) => {
this.addCorsHeaders(res);
res.onAborted(() => {
console.warn('/map request was aborted');
})
const query = parse(req.getQuery());
if (typeof query.organizationSlug !== 'string') {
@ -42,9 +46,14 @@ export class MapController extends BaseController{
}
(async () => {
const mapDetails = await adminApi.fetchMapDetails(query.organizationSlug as string, query.worldSlug as string, query.roomSlug as string|undefined);
try {
const mapDetails = await adminApi.fetchMapDetails(query.organizationSlug as string, query.worldSlug as string, query.roomSlug as string|undefined);
res.writeStatus("200 OK").end(JSON.stringify(mapDetails));
res.writeStatus("200 OK").end(JSON.stringify(mapDetails));
} catch (e) {
console.error(e);
res.writeStatus("500 Internal Server Error").end("An error occurred");
}
})();
});

View File

@ -17,13 +17,13 @@ class AdminApi {
return Promise.reject('No admin backoffice set!');
}
const params: { organizationSlug: string, worldSlug: string, mapSlug?: string } = {
const params: { organizationSlug: string, worldSlug: string, roomSlug?: string } = {
organizationSlug,
worldSlug
};
if (roomSlug) {
params.mapSlug = roomSlug;
params.roomSlug = roomSlug;
}
const res = await Axios.get(ADMIN_API_URL+'/api/map',