Fix woka endpoints on pusher

This commit is contained in:
Alexis Faizeau
2022-02-24 14:10:23 +01:00
parent c37046e138
commit 586e829e2e
4 changed files with 27 additions and 77 deletions
+23 -20
View File
@@ -1,13 +1,33 @@
import { hasToken } from "../Middleware/HasToken";
import { BaseHttpController } from "./BaseHttpController";
import { wokaService } from "../Services/WokaService";
import * as tg from "generic-type-guard";
export class WokaListController extends BaseHttpController {
routes() {
// eslint-disable-next-line @typescript-eslint/no-misused-promises
this.app.get("/woka-list", {}, async (req, res) => {
this.app.get("/woka/list/:roomId", {}, async (req, res) => {
const token = req.header("Authorization");
const wokaList = await wokaService.getWokaList(token);
if (!token) {
res.status(401).send("Undefined authorization header");
return;
}
const isParameters = new tg.IsInterface()
.withProperties({
roomId: tg.isString,
})
.withOptionalProperties({
messages: tg.isArray(tg.isUnknown),
})
.get();
if (!isParameters(req.path_parameters)) {
return res.status(400).send("Unknown parameters");
}
const roomId = req.path_parameters.roomId;
const wokaList = await wokaService.getWokaList(roomId, token);
if (!wokaList) {
return res.status(500).send("Error on getting woka list");
@@ -15,22 +35,5 @@ export class WokaListController extends BaseHttpController {
return res.status(200).json(wokaList);
});
// eslint-disable-next-line @typescript-eslint/no-misused-promises
/*this.app.post("/woka-details", async (req, res) => {
const body = await req.json();
if (!body || !body.textureIds) {
return res.status(400);
}
const textureIds = body.textureIds;
const wokaDetails = await wokaService.fetchWokaDetails(textureIds);
if (!wokaDetails) {
return res.json({ details: [] });
}
return res.json(wokaDetails);
});*/
}
}