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

fastify-websocket

Package Overview
Dependencies
Maintainers
8
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify-websocket - npm Package Compare versions

Comparing version 1.1.2 to 2.0.0

.dependabot/config.yml

100

index.d.ts
/// <reference types="node" />
import { IncomingMessage, ServerResponse, Server } from 'http';
import { Plugin } from 'fastify';
import { FastifyPlugin, FastifyRequest, RawServerBase, RawServerDefault, RawRequestDefaultExpression, RawReplyDefaultExpression, RequestGenericInterface, ContextConfigDefault } from 'fastify';
import * as WebSocket from 'ws';

@@ -9,69 +9,28 @@ import { Duplex } from 'stream';

interface RouteShorthandOptions<
HttpServer,
HttpRequest,
HttpResponse,
Query,
Params,
Headers,
Body
RawServer extends RawServerBase = RawServerDefault
> {
websocket?: boolean;
}
interface FastifyInstance<
HttpServer = Server,
HttpRequest = IncomingMessage,
HttpResponse = ServerResponse
> {
get<
Query = DefaultQuery,
Params = DefaultParams,
Headers = DefaultHeaders,
Body = DefaultBody
>(
url: string,
opts: RouteShorthandOptions<
HttpServer,
HttpRequest,
HttpResponse,
Query,
Params,
Headers,
Body
>,
handler?: WebsocketHandler<HttpRequest, HttpResponse>
): FastifyInstance<HttpServer, HttpRequest, HttpResponse>;
websocketServer: WebSocket.Server;
interface FastifyInstance<RawServer, RawRequest, RawReply> {
get: RouteShorthandMethod<RawServer, RawRequest, RawReply>
websocketServer: WebSocket.Server,
}
interface RouteOptions<
HttpServer = Server,
HttpRequest = IncomingMessage,
HttpResponse = ServerResponse,
Query = DefaultQuery,
Params = DefaultParams,
Headers = DefaultHeaders,
Body = DefaultBody
interface RouteShorthandMethod<
RawServer extends RawServerBase = RawServerDefault,
RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
> {
wsHandler?: WebsocketHandler<
HttpRequest,
HttpResponse,
Query,
Params,
Headers,
Body
>;
<RequestGeneric extends RequestGenericInterface = RequestGenericInterface, ContextConfig = ContextConfigDefault>(
path: string,
opts: RouteShorthandOptions<RawServer, RawRequest, RawReply, RequestGeneric, ContextConfig>,
handler?: WebsocketHandler
): FastifyInstance<RawServer, RawRequest, RawReply>;
}
export type WebsocketHandler<
HttpRequest = IncomingMessage,
HttpResponse = ServerResponse,
Query = DefaultQuery,
Params = DefaultParams,
Headers = DefaultHeaders,
Body = DefaultBody
> = (
this: FastifyInstance<Server, HttpRequest, HttpResponse>,
connection: websocketPlugin.SocketStream,
request: FastifyRequest<HttpRequest, Query, Params, Headers, Body>,
export type WebsocketHandler = (
this: FastifyInstance<Server, IncomingMessage, ServerResponse>,
connection: SocketStream,
request: FastifyRequest,
params?: { [key: string]: any }

@@ -81,20 +40,13 @@ ) => void | Promise<any>;

declare namespace websocketPlugin {
export interface SocketStream extends Duplex {
socket: WebSocket;
}
export interface SocketStream extends Duplex {
socket: WebSocket;
}
export interface PluginOptions {
handle?: (connection: SocketStream) => void;
options?: WebSocket.ServerOptions;
}
export interface WebsocketPluginOptions {
handle?: (connection: SocketStream) => void;
options?: WebSocket.ServerOptions;
}
declare const websocketPlugin: Plugin<
Server,
IncomingMessage,
ServerResponse,
websocketPlugin.PluginOptions
>;
declare const websocketPlugin: FastifyPlugin<WebsocketPluginOptions>;
export = websocketPlugin;
export default websocketPlugin;

@@ -79,4 +79,4 @@ 'use strict'

module.exports = fp(fastifyWebsocket, {
fastify: '>=2.4.1',
fastify: '3.x',
name: 'fastify-websocket'
})
{
"name": "fastify-websocket",
"version": "1.1.2",
"version": "2.0.0",
"description": "basic websocket support for fastify",

@@ -15,3 +15,3 @@ "main": "index.js",

"test:ts": "tsd",
"test": "npm run test:js && npm run test:ts"
"test": "npm run lint && npm run test:js && npm run test:ts"
},

@@ -33,20 +33,15 @@ "repository": {

"devDependencies": {
"@types/ws": "^6.0.3",
"fastify": "^2.13.0",
"@types/ws": "^7.2.4",
"fastify": "^3.0.0-rc.1",
"pre-commit": "^1.2.2",
"snazzy": "^8.0.0",
"standard": "^14.3.3",
"tap": "^12.7.0",
"tap": "^14.10.7",
"tsd": "^0.11.0"
},
"dependencies": {
"fastify-plugin": "^1.6.1",
"find-my-way": "^2.2.2",
"fastify-plugin": "^2.0.0",
"find-my-way": "^3.0.0",
"ws": "^7.2.3"
},
"greenkeeper": {
"ignore": [
"tap"
]
}
}
# fastify-websocket
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/) [![Build Status](https://travis-ci.org/fastify/fastify-websocket.svg?branch=master)](https://travis-ci.org/fastify/fastify-websocket) [![Greenkeeper badge](https://badges.greenkeeper.io/fastify/fastify-websocket.svg)](https://greenkeeper.io/)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)
![CI
workflow](https://github.com/fastify/fastify-websocket/workflows/CI%20workflow/badge.svg)

@@ -14,6 +16,2 @@ WebSocket support for [Fastify](https://github.com/fastify/fastify).

## Requirements
* `>=nodejs-8.0.0`
## Usage

@@ -20,0 +18,0 @@

@@ -1,6 +0,5 @@

const wsPlugin = require('../..');
const fastify = require('fastify');
import { SocketStream } from '../..';
import { WebsocketHandler, FastifyRequest, FastifyInstance } from 'fastify';
import wsPlugin, { SocketStream } from '../..';
import fastify, { WebsocketHandler, FastifyRequest, FastifyInstance, RequestGenericInterface } from 'fastify';
import { expectType } from 'tsd';
import { Server as HttpServer, IncomingMessage } from 'http'
import { Server } from 'ws';

@@ -15,11 +14,16 @@

expectType<Server>(app.websocketServer);
expectType<FastifyRequest<HttpServer, IncomingMessage, RequestGenericInterface>>(req)
expectType<{ [key: string]: any } | undefined>(params);
};
const handle = (connection: SocketStream): void => {
expectType<SocketStream>(connection)
}
const app: FastifyInstance = fastify();
app.register(wsPlugin);
app.register(wsPlugin, {});
app.register(wsPlugin, { handler });
app.register(wsPlugin, { handle } );
app.register(wsPlugin, { options: { perMessageDeflate: true } });
app.get('/', { websocket: true }, handler);
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