Skip to content

Commit 55a2028

Browse files
authored
Add websocketServer type (#51)
* Add websocketServer type * Add TS test for app.websocketServer
1 parent 688ecd5 commit 55a2028

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ declare module 'fastify' {
4040
>,
4141
handler?: WebsocketHandler<HttpRequest, HttpResponse>
4242
): FastifyInstance<HttpServer, HttpRequest, HttpResponse>;
43+
44+
websocketServer: WebSocket.Server;
4345
}
4446

4547
interface RouteOptions<

test/types/index.test-d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const fastify = require('fastify');
33
import { SocketStream } from '../..';
44
import { WebsocketHandler, FastifyRequest, FastifyInstance } from 'fastify';
55
import { expectType } from 'tsd';
6+
import { Server } from 'ws';
67

78
const app: FastifyInstance = fastify();
89
app.register(wsPlugin);
@@ -13,6 +14,7 @@ const handler: WebsocketHandler = (
1314
params
1415
) => {
1516
expectType<SocketStream>(connection);
17+
expectType<Server>(app.websocketServer);
1618
expectType<{ [key: string]: any } | undefined>(params);
1719
};
1820

0 commit comments

Comments
 (0)