I have a route.js which looks like this:
module.exports = function(app) {
app.get(\'/tip\', function(req, res) {
res.render(\"tip\");
});
app.get
Here is what I did to create dynamic APIs while I am in control over which API allows access to which methods. To maintain the APIs from now on, you can just edit the APIs array.
const APIs = [
{
route: 'order',
methods: ['get', 'post']
},
{
route: 'item',
methods: ['get']
},
]
APIs.forEach(api => {
api.methods.forEach(method => {
app[method]('/' + api.route, (req, res) => require('./routes/' + api.route)[method](req, res))
})
})