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 @@@@@@
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 Gizmo = require './model/gizmo' @use 'bodyParser''methodOverride'@approuter'static' @configure : => @use errorHandler: dumpExceptions: on : => @use 'errorHandler' @get '/': -> @render 'index' @get '/gizmos/:id': -> GizmofindById @paramsid @render index: errgizmo @on : -> @emit welcome: time: @on : -> @broadcast shout: @idtext: @datatext
Equivalent to this:
express = require 'express'app = expresscreateServerio = require'socket.io'listenapp Gizmo = require './model/gizmo' appuse expressbodyParserappuse expressmethodOverrideappuse approuterappuse expressstatic __dirname + '/public' appconfigure 'development'-> appuse expresserrorHandler dumpExceptions: on appconfigure 'production'-> appuse expresserrorHandler appget '/' resrender 'index' appget '/gizmos/:id' GizmofindById reqparamsid resrender 'index'errgizmo iosocketson 'connection' socketemit 'welcome'time: socketon 'shout' socketbroadcastemit 'shout' id: socketidtext: datatext applisten 3000 consolelog "Express server listening on port %d in %s mode" appaddressportappsettingsenv
And throws in some additional features while at it:
require @enable 'default layout''serve jquery' 'serve sammy''minify' @get '/': -> @render 'index' @on : -> @emit welcome: result: sum 12 @shared '/shared.js': -> root = window ? global = x + y @client '/index.js': -> @connect @get '#/route': -> $'body'append 'client routes!' @on : -> $'body'append "welcomed: " @view : -> @title = 'PicoChat!' @scripts = '/socket.io/socket.io''/zappa/jquery' '/zappa/sammy''/zappa/zappa''/shared''/index' h1 @title
Learn More
-
Get the gist with the crash course
-
Check the API reference
-
See the examples included with the source
-
Read the annotated source generated by docco
Other resources
-
The source code repository at github
-
Questions, suggestions? Drop us a line on the mailing list
-
Rather do it realtime? Join the IRC channel on freenode: [#zappajs]((irc://irc.freenode.net/zappajs)
-
Found a bug? Open an issue at github
-
Check the project's history at the change log
-
Migrating from an earlier version? Read the announcements (0.2.x/0.3.x) for an overview on changes, and follow the TL;DR migration guides (0.2.x/0.3.x)
-
Deploying to heroku? Check this blog post
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.
Also:
-
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