mirror of
https://github.com/matt-fidd/stratos.git
synced 2026-01-01 16:19:26 +00:00
Added priority system for route loading
This commit is contained in:
12
app.js
12
app.js
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user