This commit is contained in:
David Négrier 2021-12-06 18:34:09 +01:00
parent 84f7a8c383
commit b9840cfa3d

View File

@ -23,35 +23,37 @@ export class DebugController {
.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;
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";
}
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;
}
return obj;
} else {
return value;
}
})
)
);
})().catch(e => {
})().catch((e) => {
console.error(e);
res.writeStatus("500");
res.end("An error occurred");