1
0
mirror of https://github.com/matt-fidd/stratos.git synced 2026-01-01 20:59:30 +00:00

Added priority system for route loading

This commit is contained in:
2022-04-18 14:49:35 +00:00
parent 58855dcfd1
commit 5cbd2831d1

12
app.js
View File

@@ -30,10 +30,18 @@ function loadRoutes() {
for (const file of routeFiles) {
const route = require(path.join(__dirname, 'routes', file));
routes.push([ route.root, route.router ]);
routes.push([ route.root, route.router, route.priority, file ]);
}
return routes;
return routes.sort((a, b) => {
if (a[2] > b[2] || b[2] == null)
return 1;
if (a[2] < b[2] || a[2] == null)
return -1;
return 0;
});
}
async function main() {