GithubHelp home page GithubHelp logo

web5design / expresslane Goto Github PK

View Code? Open in Web Editor NEW

This project forked from developmentseed/expresslane

0.0 3.0 0.0 60 KB

Build express applications faster! (by taking a couple of assumptions)

expresslane's Introduction

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.

expresslane's People

Contributors

wildintellect avatar wrynearson avatar ianshward avatar miccolis avatar

Watchers

JT5D avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.