@types/express-ws-routes
TypeScript icon, indicating that this package has built-in type declarations

1.1.4 • Public • Published

Installation

npm install --save @types/express-ws-routes

Summary

This package contains type definitions for express-ws-routes (https://github.com/amekkawi/express-ws-routes).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/express-ws-routes.

index.d.ts

import { Express as exExpress, NextFunction, Request } from "express";
import { Router as coreRouter } from "express-serve-static-core";
import { Server as httpServer } from "http";
import * as WebSocket from "ws";

declare function expressWsRoutes(): expressWsRoutes.Express;

declare namespace expressWsRoutes {
    interface ClientInfo {
        origin: string;
        secure: boolean;
        req: Request;
    }
    type WebSocketHandler = (socket: WebSocket) => void;
    type CbHandler = (connectHandler: WebSocketHandler | boolean) => void;
    type WebSocketRouteHandler = (info: ClientInfo, cb: CbHandler, next: NextFunction) => void;

    interface Server extends httpServer {
        wsServer: WebSocket.Server;
    }

    interface Express extends exExpress {
        websocket(route: string, handler: WebSocketRouteHandler): Express;
    }

    interface Router extends coreRouter {
        websocket(route: string, handler: WebSocketRouteHandler): Router;
    }
}

export = expressWsRoutes;

Additional Details

Credits

These definitions were written by Gregor Stamać.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/express-ws-routes

Weekly Downloads

251

Version

1.1.4

License

MIT

Unpacked Size

4.93 kB

Total Files

5

Last publish

Collaborators

  • types