O'Reilly logo

Web Development with MongoDB and NodeJS - Second Edition by Jason Krol, Bruno Joseph D'mello, Mithun Satheesh

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The configure module

Since we are leaving our server.js file very lean, there is still a fair amount of logic that is required in configuring our server. For this, we will defer to a custom module that we'll create called configure. To get started, create a configure.js file in the server folder. We have already installed the custom dependencies when we were installing Express in the first place.

Now that the module is installed and ready to be used, let's start writing the configure.js file. First, like any of our modules, we will declare our dependencies:

var path = require('path'), routes = require('./routes'), exphbs = require('express-handlebars'),), express = require('express'), bodyParser = require('body-parser'), cookieParser = require('cookie-parser'), ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required