From cb26af0252839149463b5413a22867b1d9bdd6de Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sat, 16 Nov 2019 19:51:29 -0500 Subject: [PATCH] Fix module loading --- src/api/Server.ts | 4 +++- src/api/routes/Account.ts | 2 +- src/class/Route.ts | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) 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: {