6.5.0 • Published 7 years ago

zappajs v6.5.0

Weekly downloads
685
License
-
Repository
github
Last release
7 years ago

Zappa is a CoffeeScript-optimized interface to Express and Socket.IO.

Build Status

Synopsis

require('./zappajs') ->

  ## Server-side ##
  teacup = @teacup

  @get '/': ->
    @render 'index',
      title: 'Zappa!'
      scripts: '/index.js /more.js /client.js'
      stylesheet: '/index.css'

  @view index: ->
    {doctype,html,head,title,script,link,body,h1,div} = teacup
    doctype 5
    html =>
      head =>
        title @title if @title
        for s in @scripts.split ' '
          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: "#{pixels}px"

  @get '/:name/data.json': ->
    record =
      id: 123
      name: @params.name
      email: "#{@params.name}@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 @session.MemoryStore()
    secret: 'foo'
    resave: true, saveUninitialized: true

  @on 'ready': ->
    console.log "Client #{@id} is ready and says #{@data}."
    @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

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.

6.5.0

7 years ago

6.4.1

7 years ago

6.4.0

7 years ago

6.3.0

7 years ago

6.2.0

7 years ago

6.1.0

7 years ago

6.0.4

7 years ago

6.0.3

8 years ago

6.0.2

8 years ago

6.0.1

8 years ago

5.3.1

8 years ago

6.0.0

8 years ago

5.3.0

8 years ago

5.2.0

8 years ago

5.1.0

8 years ago

5.0.1

8 years ago

5.0.0

8 years ago

4.1.4

8 years ago

4.1.3

8 years ago

4.1.2

8 years ago

4.1.1

8 years ago

4.1.0

8 years ago

4.0.2

8 years ago

4.0.1

8 years ago

4.0.0

8 years ago

4.0.0-7

8 years ago

4.0.0-6

8 years ago

4.0.0-5

8 years ago

4.0.0-4

8 years ago

3.2.0

8 years ago

4.0.0-3

8 years ago

4.0.0-2

8 years ago

4.0.0-1

8 years ago

4.0.0-0

8 years ago

3.1.1

9 years ago

3.1.0

9 years ago

3.0.1

9 years ago

3.0.0

9 years ago

2.2.1

9 years ago

2.2.0

9 years ago

2.1.3

9 years ago

2.1.2

9 years ago

2.1.1

9 years ago

2.1.0

9 years ago

2.0.3

9 years ago

2.0.2

9 years ago

2.0.1

9 years ago

2.0.0

9 years ago

1.3.1

9 years ago

1.3.0

9 years ago

0.6.0

9 years ago

1.2.0

10 years ago

1.1.0

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.5.0

10 years ago

0.4.22

11 years ago

0.4.21

11 years ago

0.4.20

11 years ago

0.4.19

11 years ago

0.4.18

11 years ago

0.4.17

11 years ago

0.4.16

11 years ago

0.4.15

11 years ago

0.4.14

11 years ago

0.4.13

11 years ago

0.4.12

12 years ago

0.4.11

12 years ago

0.4.10

12 years ago

0.4.9

12 years ago

0.4.8

12 years ago

0.4.7

12 years ago

0.4.6

12 years ago

0.4.5

12 years ago

0.4.4

12 years ago

0.4.3

12 years ago

0.3.10

12 years ago

0.4.2

12 years ago

0.4.1

12 years ago

0.4.0

12 years ago

0.3.9

12 years ago

0.3.8

12 years ago

0.3.7

12 years ago

0.3.6

12 years ago

0.3.5

12 years ago

0.3.4

12 years ago