Fixing warning in lint

This commit is contained in:
David Négrier 2021-12-03 18:29:36 +01:00
parent 0a3417e813
commit 6427d85c24

View File

@ -11,44 +11,51 @@ export class DebugController {
} }
getDump() { getDump() {
this.App.get("/dump", async (res: HttpResponse, req: HttpRequest) => { this.App.get("/dump", (res: HttpResponse, req: HttpRequest) => {
const query = parse(req.getQuery()); (async () => {
const query = parse(req.getQuery());
if (query.token !== ADMIN_API_TOKEN) { if (query.token !== ADMIN_API_TOKEN) {
return res.writeStatus("401 Unauthorized").end("Invalid token sent!"); return res.writeStatus("401 Unauthorized").end("Invalid token sent!");
} }
return res return res
.writeStatus("200 OK") .writeStatus("200 OK")
.writeHeader("Content-Type", "application/json") .writeHeader("Content-Type", "application/json")
.end( .end(
stringify(await Promise.all(socketManager.getWorlds().values()), (key: unknown, value: unknown) => { stringify(await Promise.all(socketManager.getWorlds().values()), (key: unknown, value: unknown) => {
if (key === "listeners") { if (key === "listeners") {
return "Listeners"; return "Listeners";
}
if (key === "socket") {
return "Socket";
}
if (key === "batchedMessages") {
return "BatchedMessages";
}
if (value instanceof Map) {
const obj: any = {}; // eslint-disable-line @typescript-eslint/no-explicit-any
for (const [mapKey, mapValue] of value.entries()) {
obj[mapKey] = mapValue;
} }
return obj; if (key === "socket") {
} else if (value instanceof Set) { return "Socket";
const obj: Array<unknown> = [];
for (const [setKey, setValue] of value.entries()) {
obj.push(setValue);
} }
return obj; if (key === "batchedMessages") {
} else { return "BatchedMessages";
return value; }
} if (value instanceof Map) {
}) const obj: any = {}; // eslint-disable-line @typescript-eslint/no-explicit-any
); for (const [mapKey, mapValue] of value.entries()) {
obj[mapKey] = mapValue;
}
return obj;
} else if (value instanceof Set) {
const obj: Array<unknown> = [];
for (const [setKey, setValue] of value.entries()) {
obj.push(setValue);
}
return obj;
} else {
return value;
}
})
);
})().catch(e => {
console.error(e);
res.writeStatus("500");
res.end("An error occurred");
});
}); });
} }
} }