Book Image

Web Development with MongoDB and Node.js

By : Jason Krol
Book Image

Web Development with MongoDB and Node.js

By: Jason Krol

Overview of this book

Table of Contents (19 chapters)
Web Development with MongoDB and Node.js
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
12
Popular Node.js Web Frameworks
Index

Configuration 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 file named configure.js in the server folder. Let's first install the dependencies that we are going to be using inside our configure module by performing another npm install:

$ npm install express3-handlebars --save

Here we just installed Handlebars, a popular template-rendering engine for HTML pages. 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 connect = require('connect'),
    path = require('path'),
    //routes = require('./routes'),
    exphbs = require('express3-handlebars');

module.exports = function(app) {
  // configuration code...

  return app;
};

In the preceding code, we declared variables for each of...