O'Reilly logo

Express.js Blueprints by Ben Augarten, Marc Kuo, Eric Lin, Aidha Shaikh, Fabiano Pereira Soriani, Geoffrey Tisserand, Chiqing Zhang, Kan Zhang

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

Persisting data

Adding some diversity to the libraries, let's experiment with Mongojs (https://github.com/mafintosh/mongojs), a simple library for MongoDB that aims to be as close as possible to the native client.

  1. First things first, let's create a small config file, ./config.js, to store all the common data and just return a simple object with relevant configurations for each environment. For now let's just make sure we have a URLin a format accepted by Mongojs.
  2. This file should be able to hold all global configs for the app. It ensures we also have different settings depending on the environment.
    module.exports = function(env) {
      var configs = {};
      configs.dbUrl = "localhost/coffee_"+env;
      return configs;
    };
  3. This file needs to be in app.js, a central ...

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