apeman middleware package for sse
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
ci
doc
example
lib
test
.LICENSE.bud
.README.md.bud
.codeclimate.yml
.gitignore
.npmignore
.travis.yml
LICENSE
README.md
package.json
pool.js

README.md

apeman-middleware-sse

Build Status Code Climate Code Coverage npm Version JS Standard

apeman middleware package for sse

Installation

$ npm install apeman-middleware-sse --save

Usage

create an middleware instance and attach to server settings like $api of apeman projects.

Apemanfile.js

/** This is an example Apemanfile to use apeman-middleware-sse */

'use strict'

const co = require('co')
const asleep = require('asleep')

module.exports = {
  $pkg: { /* ... */ },
  $api: {
    /* ... */
    $serverMiddlewares: [
      require('apeman-middleware-sse')('/sse/bomb', (client) => co(function * () {
        let count = 10
        while (count >= 0) {
          client.send('tick', JSON.stringify(count))
          yield asleep(100)
          count--
        }
        client.send('boom!')
      }))
    ]
  }
}

Signature

apemanMiddlewareSse(pattern, handler, options) -> function

Create an middleware function

Args
Name Type Default Description
pattern string URL pattern to apply proxy.
handler function Handler function for each client
options Object {} Optional settings

License

This software is released under the MIT License.

Links