Fix module loading

merge-requests/1/merge
Matthew 2019-11-16 19:51:29 -05:00
parent 820bf7b081
commit cb26af0252
No known key found for this signature in database
GPG Key ID: 766BE43AE75F7559
3 changed files with 6 additions and 2 deletions

View File

@ -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}`);

View File

@ -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 });

View File

@ -16,6 +16,8 @@ export default class Route {
else this.conf.deprecated = conf.deprecated;
}
public bind() {}
get constants() {
return {
codes: {