Created
December 5, 2012 23:39
-
-
Save borestad/4220542 to your computer and use it in GitHub Desktop.
Express.js boilerplate - Not as pretty as Zappajs, but still more readable?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
express = require 'express' | |
engines = require 'consolidate' | |
routes = require './routes' | |
app = express() | |
exports.startServer = ((config) -> | |
server = @listen config.server.port, -> | |
console.log "Express server listening on port %d in %s mode", server.address().port, app.settings.env | |
# Main configuration | |
@configure -> | |
@set 'port', config.server.port | |
@set 'views', config.server.views.path | |
@engine config.server.views.extension, engines[config.server.views.compileWith] | |
@set 'view engine', config.server.views.extension | |
@use express.favicon() | |
@use express.bodyParser() | |
@use express.methodOverride() | |
@use express.compress() | |
@use config.server.base, @router | |
@use express.static(config.watch.compiledDir) | |
# Development configuration | |
@configure 'development', -> | |
@use express.errorHandler() | |
# Routes | |
@get '/', routes.index(config) | |
server | |
).bind(app) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment