Fork me on GitHub

Configuration

The Caboose configuration is inspired by rails, with a distinctly Node twist.


Environment

The environment is set through the CABOOSE_ENV environment variable. If CABOOSE_ENV is not set, it will default to development.

Configuration files

Config files are executed during the boot process and are asynchronous. You can change the config object passed in and when you're done, just call next(). The default application config file looks like this:

module.exports = (config, next) ->
  config.http =
    enabled: true
    port: process.env.PORT || 3000

  next()
    

config/application.coffee

The global configuration file. This will always be executed first.

config/environments

All environment-specific configuration files will be located here. Environment-specific config files will be executed after the global config file and operate the same way. Edit the config object passed in and call next().

To create a config file for a specific environment, just create a module with the same name as the environment. So for the development environment, config/environments/development.coffee would run.

NOTE: Like most of Caboose, if you'd like to write your config files in javascript, just rename [environment].coffee to [environment].js.

config/middleware.coffee

This file allows you to customize your entire middleware stack. You are passed the http object and can configure any middleware you'd like. Please note that the Caboose router is used by default and is configured by the routing DSL specified in the config/routes.coffee file.

The default middleware file looks like this:

express = require 'express'

module.exports = (http) ->
  http.use express.bodyParser()
  http.use express.methodOverride()
  http.use express.cookieParser()
  http.use express.session(secret: 'some kind of random string')
  http.use -> Caboose.app.router.route.apply(Caboose.app.router, arguments)
  http.use express.static Caboose.root.join('public').path
      

config/routes.coffee

This file contains the routing setup for your application. It configures the Caboose router.