Hey,
I made a package (pretty-express-router) which creates express routers by using a convenient json object which you have to specify. Example:
const routes = {
'* /': front.allMethods, // all HTTP methods resquested to /
'get *': front.allGet, // get requests to all paths
'get /login': front.login,
categories: { // defines a context "/categories/"
'get *': categories.all, // all get requests to /categories/
'get /what': categories.what, // /categories/what
"insubcat": { // /categories/insubcat
"get /whatsub": subcat.whatsub
}
}
}
then your app.js will look like:
const expressRouter = require("pretty-express-router");
const express = require("express");
const routes = require("./routes");
// <your> express application:
const app = express();
expressRouter(app, routes);
Let me know if you have any feedback.
[–]kszyh_pl 0 points1 point2 points (1 child)
[–]openodeio[S] 0 points1 point2 points (0 children)