I am working on re-recording an existing website using Node.js using Express.
The front of the site will use Backbone JS, and so I need all the necessary routes to match the built-in synchronous synchronization. Now, most of the client URL and for synchronization with the database will be the same. But they will not work for a regular GET, since they will need to return JSON.
So, I think it would be nice to add the extension to the Model / Collection URLs in Backbone, e.g. .json and Express, to have this for each route:
app.get('/p/:topCategory/:category/:product.:format', function(req, res) { ... });
Where if (req.params.id == 'json') than we send JSON, otherwise we will display HTML?
Or is there a better approach? Please, help.
mvbl fst
source share