apeman-middleware-sse

1.2.1 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i apeman-middleware-sse

Weekly Downloads

2

Version

1.2.1

License

MIT

Last publish

Collaborators

  • okunishinishi