node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »



layer-cake is a little node.js web framework care of your friends at MongoHQ.

Yummy Layer Cake image

The basic idea is to remove a lot of the normal boilerplate that goes into almost every express application, while adding some nice features to make your life easier.


$ npm install -g layer-cake



layer-cake command line image

Expected Directory Structure

|- app/
|  |- controllers/
|  |  |-
|  |-
|  |-
|- config/
|  |- server.json
|  |- development/
|  |  |- mongodb.json
|  |- production/
|  |  |- mongodb.json
|- lib/
|- package.json



All controllers are located in the app/controllers directory. All files inside of this directory will be required and then called, being passed the app object. Controllers can then attach route handlers to this object the same way they would to an express app.

For instance, the file could look like:

module.exports = (app) ->
index = (req, res) ->
  res.send(hello: 'world')


Middlewares work the exact same way they do in express. layer-cake will attempt to require a file at app/middleware and then pass the app object to it.

A simple might look like this:

express = require 'express'
module.exports = (app) ->
  app.use express.logger()
  app.use express.bodyParser()
  app.use express.methodOverride()
  app.use app.router



All configuration is located in the config directory. All .json, .yml, and .yaml files will be parsed and made available on the app.config object. Any configuration files in an environment-specific directory will override files from the main config directory. The current environment is read from process.env.NODE_ENV and will always default to development.

For instance, the above directory structure will result in app.config looking like this in development:

  "server": {
    // contents of my-project/app/config/server.json 
  "mongodb": {
    // contents of my-project/app/config/development/mongodb.json 


Copyright (c) 2013 MongoHQ Inc. Licensed under the MIT license.