1
0
forked from noxious/server

made typescript my bitch

This commit is contained in:
2024-05-24 19:37:15 +02:00
parent 552d9bb4db
commit cfc0f03932
9 changed files with 79 additions and 26 deletions

View File

@ -8,6 +8,7 @@ import config from './app/utilities/config';
import prisma from './app/utilities/prisma';
import api from "./app/utilities/api";
import ZoneManager from "./app/ZoneManager";
import UserManager from "./app/UserManager";
export class Server
{
@ -54,6 +55,9 @@ export class Server
// Add API routes
await api.addAuthRoutes(this.app);
// Load user manager
await UserManager.boot();
// Load zone manager
await ZoneManager.boot();
@ -70,16 +74,12 @@ export class Server
const eventsPath = path.join(__dirname, 'app', 'events');
try {
const files: string[] = await fs.promises.readdir(eventsPath);
await Promise.all(files.map(async (file) => {
try {
const module = await import(path.join(eventsPath, file));
module.default(socket, this.io);
} catch (error: any) {
console.error(`[❌] Failed to load event handler ${file}: ${error.message}`);
}
}));
for (const file of files) {
const module = await import(path.join(eventsPath, file));
module.default(socket, this.io);
}
} catch (error: any) {
throw new Error('[❌] Failed to read event handlers directory: ' + error.message);
throw new Error('[❌] Failed to load event handlers: ' + error.message);
}
}
}