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

fastify-ws

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify-ws - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

8

index.js

@@ -6,7 +6,7 @@ 'use strict'

module.exports = fp((fastify, opts, next) => {
const wsLib = opts.wsLibrary || 'ws'
const lib = opts.library || 'ws'
if (wsLib !== 'ws' && wsLib !== 'uws') return next(new Error('Invalid "wsLibrary" option'))
if (lib !== 'ws' && lib !== 'uws') return next(new Error('Invalid "library" option'))
const WebSocketServer = require(wsLib).Server
const WebSocketServer = require(lib).Server
const wss = new WebSocketServer({

@@ -16,5 +16,5 @@ server: fastify.server

fastify.decorate('wsServer', wss)
fastify.decorate('ws', wss)
next()
})
{
"name": "fastify-ws",
"version": "0.2.0",
"version": "0.3.0",
"description": "Basic WebSocket support for Fastify built on the blazing fast ws and uws libraries.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -15,3 +15,3 @@ # fastify-ws

fastify.register(require('fastify-ws'), {
wsLibrary: 'uws' // Use the uws library instead of the default ws library
library: 'uws' // Use the uws library instead of the default ws library
})

@@ -22,5 +22,5 @@

fastify.wsServer
.on('connection', ws => {
ws.on('message', msg => ws.send(msg)) // Creates an echo server
fastify.ws
.on('connection', socket => {
socket.on('message', msg => socket.send(msg)) // Creates an echo server
})

@@ -27,0 +27,0 @@ })

@@ -17,11 +17,11 @@ 'use strict'

fastify.wsServer
.on('connection', ws => {
ws.send('hello client')
fastify.ws
.on('connection', socket => {
socket.send('hello client')
ws.on('message', msg => {
socket.on('message', msg => {
t.equal(msg, 'hello server')
ws.terminate()
fastify.wsServer.close(() => fastify.close())
socket.terminate()
fastify.ws.close(() => fastify.close())

@@ -28,0 +28,0 @@ process.exit()

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