1
0
Fork 0

Fix routing order: defaultDocument->router->files

This commit is contained in:
Alan Plum 2016-06-16 12:59:06 +02:00
parent c9be12eb37
commit a70d0d75cd
No known key found for this signature in database
GPG Key ID: 8ED72A9A323B6EFD
1 changed files with 18 additions and 21 deletions

View File

@ -136,11 +136,6 @@ exports.routeService = function (service, throwOnErrors) {
service._reset();
let error = null;
if (service.legacy) {
error = routeLegacyService(service, throwOnErrors);
}
const defaultDocument = service.manifest.defaultDocument;
if (defaultDocument) {
service.routes.routes.push({
@ -156,6 +151,24 @@ exports.routeService = function (service, throwOnErrors) {
});
}
let error = null;
if (service.legacy) {
error = routeLegacyService(service, throwOnErrors);
} else {
if (service.manifest.main) {
try {
service.main.exports = service.run(service.manifest.main);
} catch (e) {
console.errorLines(`Cannot execute Foxx service at ${service.mount}: ${e.stack}`);
error = e;
if (throwOnErrors) {
throw e;
}
}
}
service.buildRoutes();
}
if (service.manifest.files) {
const files = service.manifest.files;
_.each(files, function (file, path) {
@ -177,22 +190,6 @@ exports.routeService = function (service, throwOnErrors) {
});
}
if (!service.legacy) {
if (service.manifest.main) {
try {
service.main.exports = service.run(service.manifest.main);
} catch (e) {
console.errorLines(`Cannot execute Foxx service at ${service.mount}: ${e.stack}`);
error = e;
if (throwOnErrors) {
throw e;
}
}
}
service.buildRoutes();
}
service.main.loaded = true;
return {