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() {
this.App.get("/dump", async (res: HttpResponse, req: HttpRequest) => {
const query = parse(req.getQuery());
this.App.get("/dump", (res: HttpResponse, req: HttpRequest) => {
(async () => {
const query = parse(req.getQuery());
if (query.token !== ADMIN_API_TOKEN) {
return res.writeStatus("401 Unauthorized").end("Invalid token sent!");
}
if (query.token !== ADMIN_API_TOKEN) {
return res.writeStatus("401 Unauthorized").end("Invalid token sent!");
}
return res
.writeStatus("200 OK")
.writeHeader("Content-Type", "application/json")
.end(
stringify(await Promise.all(socketManager.getWorlds().values()), (key: unknown, value: unknown) => {
if (key === "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 res
.writeStatus("200 OK")
.writeHeader("Content-Type", "application/json")
.end(
stringify(await Promise.all(socketManager.getWorlds().values()), (key: unknown, value: unknown) => {
if (key === "listeners") {
return "Listeners";
}
return obj;
} else if (value instanceof Set) {
const obj: Array<unknown> = [];
for (const [setKey, setValue] of value.entries()) {
obj.push(setValue);
if (key === "socket") {
return "Socket";
}
return obj;
} else {
return value;
}
})
);
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;
} 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");
});
});
}
}