Skip to content

Instantly share code, notes, and snippets.

@lennym
Last active December 16, 2015 05:49
Show Gist options
  • Save lennym/5387228 to your computer and use it in GitHub Desktop.
Save lennym/5387228 to your computer and use it in GitHub Desktop.
var router = require('router.js');
app.route = function (path, map) {
['get', 'post', 'put', 'delete'].forEach(function (method) {
if (typeof map[method] !== 'undefined') {
app[method](path, map[method]);
}
});
}
app.route('/path', router);
module.exports = {
get: function (req, res) { ... },
post: function (req, res) { ... }
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment