New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fastify-websocket-server

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify-websocket-server

Fastify plugin that adds websockets support

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

fastify-websocket-server

Fastify plugin that creates websocket server on your fastify instance.

NPM Version Downloads Count Vunerabilities Count Build Status Coverage Status License

ToC

Why not use fastify-ws?

  • It doesn't support all ws options in it's constructor.
  • It doesn't expose types and doesn't support typescript out of the box.

Getting started

Installation

npm i fastify-websocket-server

Usage

const fastify = require('fastify')()
const websocketPlugin = require('fastify-websocket-server');
 
fastify.register(websocketPlugin, {
  // The same options that `ws` supports
}).after((err) => {
  if (err) { throw err; }
  fastify.wss
    .on('connection', (ws) => {
      ws.on('message', (msg) => {
        socket.send(msg)); // echo message
      }
    })
})
fastify.listen(3000);

Docs

Docs available via link.

Roadmap

Any ideas or PR welcome

Support for "typed" websockets

Allow setting message types via query param or some header. This will set default message mode.

Better support for JSON messages

The idea is if websocket message type is set to JSON to add following:

  • support JSON message validation against schema, just like Fastify does.
  • use fast-json-stringify module to serialize messages with schemas

Keywords

FAQs

Package last updated on 24 Jan 2019

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