
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
@types/koa-websocket
Advanced tools
TypeScript definitions for koa-websocket
npm install --save @types/koa-websocket
This package contains type definitions for koa-websocket (https://github.com/kudos/koa-websocket).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/koa-websocket.
import Koa = require("koa");
import compose = require("koa-compose");
import * as http from "http";
import * as https from "https";
import * as ws from "ws";
declare module "koa" {
interface Context {
websocket: ws;
path: string;
}
}
declare namespace KoaWebsocket {
type Middleware<StateT = Koa.DefaultState, ContextT = Koa.DefaultContext> = compose.Middleware<
MiddlewareContext<StateT> & ContextT
>;
interface MiddlewareContext<StateT> extends Koa.Context {
// Limitation: Declaration merging cannot overwrap existing properties.
// That's why this property is here, not in the merged declaration above.
app: App;
state: StateT;
}
class Server<StateT = Koa.DefaultState, ContextT = Koa.DefaultContext> {
app: App;
middleware: Array<Middleware<StateT, ContextT>>;
server?: ws.Server | undefined;
constructor(app: Koa<StateT, ContextT>);
listen(options: ws.ServerOptions): ws.Server;
onConnection(socket: ws, request: http.IncomingMessage): void;
use(middleware: Middleware<StateT, ContextT>): this;
}
interface App<StateT = Koa.DefaultState, ContextT = Koa.DefaultContext> extends Koa<StateT, ContextT> {
ws: Server<StateT, ContextT>;
}
}
declare function KoaWebsocket<
StateT = Koa.DefaultState,
ContextT = Koa.DefaultContext,
>(
app: Koa<StateT, ContextT>,
wsOptions?: ws.ServerOptions,
httpsOptions?: https.ServerOptions,
): KoaWebsocket.App<StateT, ContextT>;
export = KoaWebsocket;
These definitions were written by Maël Lavault, Jaco Greeff, Martin Ždila, Eunchong Yu, Christopher N. Katoyi-Kaba, and Zuo Jiazi.
FAQs
TypeScript definitions for koa-websocket
The npm package @types/koa-websocket receives a total of 3,069 weekly downloads. As such, @types/koa-websocket popularity was classified as popular.
We found that @types/koa-websocket demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.