Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Build express applications faster! (by taking a couple of assumptions)
JavaScript
branch: master

remove dead code.

latest commit 2987d5fb61
Adrian Rossouw authored
Failed to load latest commit information.
lib
README.md
index.js
package.json

README.md

Express Lane

Get started building with Express fast.

Express Lane builds around these assumptions:

  • View engine is handlebars.
  • Settings are managed centrally and loaded on server object.
  • Session handling is used.

Requirements

  • Node.js
  • Connect
  • Express
  • hbs
  • A settings module that exports settings as an anonymous object:

    module.exports = { // My settings };

Express lane settings variables

  • modules (array of modules to be required on start)
  • port
  • publicHostname
  • Layout template variables
    • siteTitle
    • siteSlogan
    • entitiesRoot
    • footerMessage
    • analytics
    • feedbackMessage

Custom settings

  • Organize custom settings by module name. I. e. your module should expect settings at settings.mymodule.

Usage

// settings.js: configuration for Express Lane and Express Lane modules.
module.exports = {
    modules: [
        'train'
    ],
    train: {
        cars: 12,
        number: 502
    }
    port: 8080,
    siteTitle: 'Transport'
};

// Start express server via Express Lane
require('expresslane').start();

// Example: query settings for train module.
var settings = require('expresslane').app.set('settings)('train);

Directory structure

  • /public - static files

Messages

You can display status messages to the user like this

require('expresslane').on('renderStatusMessages', function(req, res) {
    res.statusMessages.push('Hello World');
});

Of course your layout template needs to contain {{statusMessage}}.

TODO: Page based message support would be trivial:

app.get('/', function(req, res, next) {
    res.messages.push('Hello World');
});

Environment dependent settings

Additionally to settings.js, environment dependent settings can be specified in modules named

settings.env.ENV_NAME.js

So if the application is started with NODE_ENV=production node app.js a file settings.env.production.js will be looked for and - if present - its values would be added to the ones defined in settings.js. If a value with the same key already exists in settings.js it will be overridden.

Something went wrong with that request. Please try again.