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'), morgan = require('morgan'), methodOverride = require('method-override'), errorHandler = require('errorhandler'); module.exports = function(app) { app.use(morgan('dev')); app.use(bodyParser.urlencoded...