# zappajs

> CoffeeScript minimalist interface to express, socket.io and others

Latest version **6.5.0** (published 2017-10-02) · 0 weekly downloads

## Install

```sh
npm install zappajs
pnpm add zappajs
yarn add zappajs
bun add zappajs
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 6.5.0 |
| Published | 2017-10-02 |
| First published | 2012-04-16 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 15 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 190 |
| Author | Stephane Alnet |
| Maintainers | shimaore |
| Keywords | framework, websockets, coffeescript, express, socket.io, sinatra, dsl |

## Links

- npm: https://www.npmjs.com/package/zappajs
- Repository: https://github.com/zappajs/zappajs
- Homepage: http://zappajs.github.com/zappajs/
- Issues: https://github.com/zappajs/zappajs/issues
- npm.io page: https://npm.io/package/zappajs

## Dependencies (15)

- [seem](https://npm.io/package/seem.md) ^2.0.0
- [debug](https://npm.io/package/debug.md) ^3.1.0
- [teacup](https://npm.io/package/teacup.md) ^2.0.0
- [throng](https://npm.io/package/throng.md) ^4.0.0
- [express](https://npm.io/package/express.md) ^4.16.1
- [methods](https://npm.io/package/methods.md) ^1.1.2
- [invariate](https://npm.io/package/invariate.md) ^1.3.1
- [node-uuid](https://npm.io/package/node-uuid.md) ^1.4.8
- [socket.io](https://npm.io/package/socket.io.md) ^2.0.3
- [uglify-js](https://npm.io/package/uglify-js.md) ^3.1.3
- [coffee-css](https://npm.io/package/coffee-css.md) 0.0.5
- [coffee-script](https://npm.io/package/coffee-script.md) ^1.12.7
- [express-session](https://npm.io/package/express-session.md) ^1.15.6
- [socket.io-client](https://npm.io/package/socket.io-client.md) ^2.0.3
- [coffeescript-helpers](https://npm.io/package/coffeescript-helpers.md) ^2.2.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 6.5.0 (latest) — 2017-10-02
- 5.0.0 (development) — 2016-05-28
- 0.6.0 (0.x) — 2015-01-15
- 1.2.0 (1.0) — 2014-09-15
- 0.4.11 (trunk) — 2012-10-02
- 6.4.1 — 2017-06-17
- 6.4.0 — 2017-03-21
- 6.3.0 — 2017-03-02
- 6.2.0 — 2016-11-11
- 6.1.0 — 2016-11-09
- 6.0.4 — 2016-11-03
- 6.0.3 — 2016-10-13
- 6.0.2 — 2016-08-23
- 5.2.0 — 2016-08-16
- 5.1.0 — 2016-08-06
- … 60 more at https://npm.io/package/zappajs/versions

## README

Zappa is a [CoffeeScript](http://coffeescript.org)-optimized interface to [Express](http://expressjs.com) and [Socket.IO](http://socket.io).

[![Build Status](https://secure.travis-ci.org/zappajs/zappajs.png?branch=6.x)](http://travis-ci.org/zappajs/zappajs)

## Synopsis

```coffee
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

- The source code [repository](http://github.com/zappajs/zappajs) at github

- Questions, suggestions? Drop us a line on the [mailing list](http://groups.google.com/group/zappajs)

- Found a bug? Open an [issue](http://github.com/zappajs/zappajs/issues) 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`](https://github.com/zappajs/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.

---
_Source: https://npm.io/package/zappajs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
