Skip to content

Instantly share code, notes, and snippets.

@deedubs
Created July 10, 2013 13:49
Show Gist options
  • Save deedubs/5966418 to your computer and use it in GitHub Desktop.
Save deedubs/5966418 to your computer and use it in GitHub Desktop.
Modularized Express
var express = require('express');
var server = express();
server.use('/products', require('./products'))
server.listen(8080);
var express = require('express');
var products = module.exports = express();
var Products = require('./lib/products');
products.get('/', function (req, res, next) {
Products.find(function (err, products) {
if (err) {
return next(err);
}
res.json(products);
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment