Wiring up a NoSQL database module to Express
Now that we have automated tests for the model and a user-defined module which makes use of it, let's build a sample Express-based application exposing this module via HTTP:
var express = require('express') , http = require('http') , path = require('path') , bodyParser = require('body-parser') , logger = require('morgan') , methodOverride = require('method-override') , errorHandler = require('errorhandler') , mongoose = require('mongoose') , dataservice = require('./modules/contactdataservice'); var app = express(); var url = require('url'); // all environments app.set('port', process.env.PORT || 3000); app.set('views', __dirname + '/views'); app.set('view engine', 'jade'); app.use(methodOverride()); app.use(bodyParser.json()); // development only if ('development' == app.get('env')) { app.use(errorHandler()); ...