fix: don't crash the server if a route fails to load
This commit is contained in:
parent
04660dbce1
commit
6fee07d9e1
|
@ -70,9 +70,13 @@ class Server {
|
||||||
let routes = [RouteClass];
|
let routes = [RouteClass];
|
||||||
if (Array.isArray(RouteClass)) routes = RouteClass;
|
if (Array.isArray(RouteClass)) routes = RouteClass;
|
||||||
for (const File of routes) {
|
for (const File of routes) {
|
||||||
const route = new File();
|
try {
|
||||||
this.server[route.method](process.env.ROUTE_PREFIX + route.path, route.authorize.bind(route));
|
const route = new File();
|
||||||
log.info(`Found route ${route.method.toUpperCase()} ${process.env.ROUTE_PREFIX}${route.path}`);
|
this.server[route.method](process.env.ROUTE_PREFIX + route.path, route.authorize.bind(route));
|
||||||
|
log.info(`Found route ${route.method.toUpperCase()} ${process.env.ROUTE_PREFIX}${route.path}`);
|
||||||
|
} catch (e) {
|
||||||
|
log.error(`Failed loading route from file ${routeFile} with error: ${e.message}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue