1.1.3 • Published 8 months ago

passing-notes-websocket v1.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

passing-notes-websocket

npm CI Status

A middleware for accepting WebSocket connections

Usage

Install passing-notes-websocket by running:

yarn add passing-notes-websocket

Then, compose it with other middleware, or at least a default handler:

import {compose} from 'passing-notes'
import serveWebSocket from 'passing-notes-websocket'

export default compose(
  serveWebSocket((ws) => {
    ws.on('message', (message) => {
      console.log(message)
    })

    ws.send('Hello World!')
  }),
  () => () => ({status: 404})
)

serveWebSocket will look for HTTP/1.1 Upgrade requests that ask for Upgrade: websocket. It will then negotiate the upgrade and provide a WebSocket object. Otherwise, it delegates to the next middleware.

1.1.3

8 months ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago