I would like to "get rid" of the router in node.js. Currently, what I have is something that looks like this:
app.get '/thing1', (req, res) ->
res.render 'thing1'
app.get '/thing2', (req, res) ->
res.render 'thing2'
Is there a way to collapse these to something like this:
app.get '/(*)', (req, res) ->
res.render '(*)'
PS: I'm using coffeescript, but an answer in any language is OK
app.get('/:thing', function (req, res) {
res.render(req.params.thing)
})
From http://expressjs.com/api.html#app.VERB :
app.get(/^(.*)$/, function(req, res, next){
res.send(req.params[0]);
});
Working gist: https://gist.github.com/elliotf/5826944