1
0
Fork 0

add logging to Server.loadRoutes()

refactor/models
Matthew 2019-11-16 19:38:59 -05:00
parent e24bca245e
commit 2ab5d40c55
No known key found for this signature in database
GPG Key ID: 766BE43AE75F7559
1 changed files with 8 additions and 3 deletions

View File

@ -31,9 +31,14 @@ export default class Server {
const routes = await fs.readdir('./routes'); const routes = await fs.readdir('./routes');
routes.forEach(async (routeFile) => { routes.forEach(async (routeFile) => {
if (routeFile === 'index.js') return; if (routeFile === 'index.js') return;
try {
const route: Route = new (require(`./${routeFile}`))(this); const route: Route = new (require(`./${routeFile}`))(this);
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}`);
} catch (error) {
this.client.signale.error(error);
}
}); });
} }