apeman-middleware-sse
apeman middleware package for sse
Last updated a year ago by okunishinishi .
MIT · Repository · Bugs · Original npm · Tarball
$ cnpm install apeman-middleware-sse 
SYNC missed versions from official npm registry.

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

Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 14
Dependencies (4)
Dev Dependencies (14)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |