Zappa is a CoffeeScript-optimized interface to Express and Socket.IO.
Synopsis
require ## Server-side ## teacup = @teacup @get '/': -> @render 'index' title: 'Zappa!' scripts: '/index.js /more.js /client.js' stylesheet: '/index.css' @view : -> teacup doctype 5 html => head => title @title if @title for s in @scriptssplit ' ' script src: s link rel:'stylesheet'href:@stylesheet body -> h1 'Welcome to Zappa!' div id:'content' div id:'content2' pixels = 12 @css '/index.css': body: font: '12px Helvetica' h1: color: 'pink' height: "px" @get '/:name/data.json': -> record = id: 123 name: @paramsname email: "@example.com" @json record ## Client-side ## @coffee '/index.js': -> alert 'hi' ## Client-side with Browserify ## @with 'client' # requires `zappajs-plugin-client` @browser '/more.js': -> domready = require 'domready' $ = require 'component-dom' domready -> $'#content'html 'Ready to roll!' ## Client-side with ExpressJS/Socket.IO session sharing ## @use session: store: new @sessionMemoryStore secret: 'foo' resave: truesaveUninitialized: true @on 'ready': -> consolelog "Client is ready and says ." @emit 'ok'null @client '/client.js': -> @emit 'ready''hello' $ = require 'component-dom' @on 'ok'-> $'#content2'html 'Ready to roll too!'
Install
npm install zappajs
Other resources
-
The source code repository at github
-
Questions, suggestions? Drop us a line on the mailing list
-
Found a bug? Open an issue at github
ZappaJS 5.0 Changes
Removal of browserify dependency
@browser
and @isomorph
are now in the client
module, alongside @client
.
ZappaJS 4.0 Changes
Major improvements in Socket.IO interface:
Now supports saving the Session object in Socket.IO methods. Session content can be modified both from ExpressJS and from Socket.IO.
Supports ack
callback for all Socket.IO emit
calls.
Embedded client-side code:
The ZappaJS client is no longer embedded and was moved to a separate module, zappajs-client
.
Sammy and jQuery are no longer embedded:
- As a consequence the
zappa
middleware is no longer required and was removed. If your code references any Javascript file under/zappa/
, consider using e.g.browserify-middleware
to build the dependencies. - Also,
@client
and@shared
are gone (along with their magic).
Client-side code is now bundled using browserify-string
; @browser
is available alongside @client
, while @isomorph
replaces @shared
.
New features
Now uses the debug
module instead of logging to console directly.
Host and port might be specified using the ZAPPA_PORT
and ZAPPA_HOST
environment variables, which are used as default if no explicit configuration is provided.