Skip to content

Instantly share code, notes, and snippets.

@jgable
Created April 1, 2013 17:56
Show Gist options
  • Save jgable/5286522 to your computer and use it in GitHub Desktop.
Save jgable/5286522 to your computer and use it in GitHub Desktop.
Abstracting express routes
var express = require("express");
var routes = require("./lib/routes");
// You're existing code to instantiate the app.
var app = express();
// ... and configure it...
// Set your routes.
routes.init(app);
app.listen(3000, function(err) {
if(err) {
throw err;
}
console.log("Listening on port 3000");
})
var data = require("./data");
module.exports = {
init: function(app) {
// Home page...
app.get('/', function(req, res) {
resp.render("index");
});
// Etc...
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment