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()); ...

Get RESTful Web API Design with Node.js - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.