Skip to content


Subversion checkout URL

You can clone with
Download ZIP
web application framework for node built on express and, based on mauricemach/zappa
CoffeeScript HTML Shell

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.

8888888888P        d8888 8888888b.  8888888b.     d8888          @@@    @@@ 
      d88P        d88888 888   Y88b 888   Y88b   d88888        @@@@@@@@@@@@@@
     d88P        d88P888 888    888 888    888  d88P888       @@@@@@@@@@@@@@@@
    d88P        d88P 888 888   d88P 888   d88P d88P 888      @@@@@@@@  @@@@@@@@
   d88P        d88P  888 8888888P"  8888888P" d88P  888      @@@            @@@
  d88P        d88P   888 888        888      d88P   888      @@   @@@@@@@@   @@
 d88P        d8888888888 888        888     d8888888888           @@@@@@@@    
d8888888888 d88P     888 888        888    d88P     888 JS         @@@@@@     

Node development for the lazy

If you can describe it in 495 characters, why on earth should it take 879?

Zappa is a CoffeeScript-optimized interface to Express and Socket.IO that makes this:

require('zappajs') ->
  Gizmo = require './model/gizmo'

  @use 'bodyParser', 'methodOverride', @app.router, 'static'

    development: => @use errorHandler: {dumpExceptions: on}
    production: => @use 'errorHandler'

  @get '/': -> @render 'index'

  @get '/gizmos/:id': ->
    Gizmo.findById, (err, gizmo) =>
      @render index: {err, gizmo}

  @on connection: ->
    @emit welcome: {time: new Date()}

  @on shout: ->
    @broadcast shout: {@id, text: @data.text}

Equivalent to this:

express = require 'express'
app = express.createServer()
io = require('').listen(app)

Gizmo = require './model/gizmo'

app.use express.bodyParser()
app.use express.methodOverride()
app.use app.router
app.use express.static __dirname + '/public'

app.configure 'development', ->
  app.use express.errorHandler dumpExceptions: on

app.configure 'production', ->
  app.use express.errorHandler()

app.get '/', (req, res) -> res.render 'index'

app.get '/gizmos/:id', (req, res) ->
  Gizmo.findById, (err, gizmo) ->
    res.render 'index', {err, gizmo}

io.sockets.on 'connection', (socket) ->
  socket.emit 'welcome', time: new Date()

  socket.on 'shout', (data) ->
    socket.broadcast.emit 'shout',
      id:, text: data.text

app.listen 3000

console.log "Express server listening on port %d in %s mode",
  app.address().port, app.settings.env

And throws in some additional features while at it:

require('zappajs') ->
  @enable 'default layout', 'minify'

  @get '/': ->
    @render 'index',
      title: 'Picochat!'
      scripts = [

  @on connection: ->
    @emit welcome: {result: sum 1, 2}

  @shared '/shared.js': ->
    root = window ? global
    root.sum = (x, y) -> x + y

  @client '/index.js': ->

    @get '#/route': ->
      $('body').append 'client routes!'

    @on welcome: ->
      $('body').append "welcomed: #{sum @data.result, 2}"

  @css '/default.css':
      border: none

  @view index: ->
    h1 @title


npm install zappajs

This will install v0.3, which depends on Express 2.5. If you would rather use Express 3.0:

npm install zappajs@0.4

Learn More

Other resources

Build Status

Thanks loads

To all people behind the excellent libs that made this little project possible, more specifically:

  • Jeremy Ashkenas for CoffeeScript, the "little" language is nothing short of revolutionary to me.

  • TJ Holowaychuk for the robust and flexible cornerstone that's Express.

  • Guillermo Rauch for solving (as far as I'm concerned) the comet problem once and for all.

  • Ryan Dahl for Node.js, without which nothing of this would be possible.


  • Blake Mizerany for Sinatra, the framework that made me redefine simple.

  • why the lucky stiff, for making me redefine hacking.

  • And last but not least Frank Zappa, for the spirit of nonconformity and experimentation that inspires me to push forward. Not to mention providing the soundtrack.

"Why do you necessarily have to be wrong just because a few million people think you are?" - FZ

Something went wrong with that request. Please try again.