Fix woka endpoints on pusher
This commit is contained in:
@@ -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);
|
||||
});*/
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user