Fix module loading
parent
820bf7b081
commit
cb26af0252
|
@ -32,7 +32,9 @@ export default class Server {
|
||||||
routes.forEach(async (routeFile) => {
|
routes.forEach(async (routeFile) => {
|
||||||
if (routeFile === 'index.js') return;
|
if (routeFile === 'index.js') return;
|
||||||
try {
|
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.routes.set(route.conf.path, route);
|
||||||
this.app.use(route.conf.path, route.router);
|
this.app.use(route.conf.path, route.router);
|
||||||
this.client.signale.success(`Successfully loaded route ${route.conf.path}`);
|
this.client.signale.success(`Successfully loaded route ${route.conf.path}`);
|
||||||
|
|
|
@ -7,7 +7,7 @@ export default class Account extends Route {
|
||||||
super(server, { path: '/account', deprecated: false });
|
super(server, { path: '/account', deprecated: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
public async bind() {
|
public bind() {
|
||||||
this.router.use(async (req, res, next) => {
|
this.router.use(async (req, res, next) => {
|
||||||
const url = new URL(req.url);
|
const url = new URL(req.url);
|
||||||
const account = await this.server.client.db.Account.findOne({ username: url.username });
|
const account = await this.server.client.db.Account.findOne({ username: url.username });
|
||||||
|
|
|
@ -16,6 +16,8 @@ export default class Route {
|
||||||
else this.conf.deprecated = conf.deprecated;
|
else this.conf.deprecated = conf.deprecated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bind() {}
|
||||||
|
|
||||||
get constants() {
|
get constants() {
|
||||||
return {
|
return {
|
||||||
codes: {
|
codes: {
|
||||||
|
|
Loading…
Reference in New Issue