Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

koa-websocket

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-websocket

Light wrapper around Koa providing a websocket middleware handler that is koa-route compatible.

  • 0.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11K
increased by2.57%
Maintainers
1
Weekly downloads
 
Created
Source

koa-websocket

Build Status

Installation

npm install koa-websocket

Usage

const koa = require('koa'),
  route = require('koa-route'),
  websockify = require('koa-websocket');

const app = websockify(koa());

// Note it's app.ws.use and not app.use
app.ws.use(route.all('/test/:id', function* (next) {
  this.send('Hello World');
  // `this` is the socket passed from WebSocketServer to connection listeners
  this.on('message', function(message) {
    // do something with the message from client
  });
  // yielding `next` will pass the socket on to the next ws middleware
}));

app.listen(3000);

Keywords

FAQs

Package last updated on 14 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc