diff --git a/src/api/Server.ts b/src/api/Server.ts index cd65289..198ca68 100644 --- a/src/api/Server.ts +++ b/src/api/Server.ts @@ -32,7 +32,9 @@ export default class Server { routes.forEach(async (routeFile) => { if (routeFile === 'index.js') return; try { - const route: Route = new (require(`${__dirname}/routes/${routeFile}`))(this); + // eslint-disable-next-line new-cap + const route: Route = new (require(`${__dirname}/routes/${routeFile}`).default)(this); + route.bind(); this.routes.set(route.conf.path, route); this.app.use(route.conf.path, route.router); this.client.signale.success(`Successfully loaded route ${route.conf.path}`); diff --git a/src/api/routes/Account.ts b/src/api/routes/Account.ts index 6e4115e..2362a6b 100644 --- a/src/api/routes/Account.ts +++ b/src/api/routes/Account.ts @@ -7,7 +7,7 @@ export default class Account extends Route { super(server, { path: '/account', deprecated: false }); } - public async bind() { + public bind() { this.router.use(async (req, res, next) => { const url = new URL(req.url); const account = await this.server.client.db.Account.findOne({ username: url.username }); diff --git a/src/class/Route.ts b/src/class/Route.ts index 2f33eec..8004fc5 100644 --- a/src/class/Route.ts +++ b/src/class/Route.ts @@ -16,6 +16,8 @@ export default class Route { else this.conf.deprecated = conf.deprecated; } + public bind() {} + get constants() { return { codes: {