I'm trying to build an application will allow me to take a String parameter from the frontend, and create an Express route from that. Is that possible?
var express = require('express');
var router = express.Router();
router.post('/newAPI/:name', function(req, res, next) {
var name = req.params.name;
router.get('/'+name, function(req, res, next) {
res.send({"name":""+name});
});
});
With this, would calling localhost:3000/newApi/bob create a new route localhost:3000/bob that returns {"name":"bob"}?
.post()that occurs creates a duplicate.get()handler. And, because none of this is remembered when your server is restarted. To get advice on a better way to solve the problem, you should describe your actual design goal and we can help with a better way to do this./:routeand then use thereq.params.routeas a key to lookup that route definition, or return an error if it doesn't exist.