diff --git a/test/types/aedes.test-d.ts b/test/types/aedes.test-d.ts index a4a813f7..d6ee934a 100644 --- a/test/types/aedes.test-d.ts +++ b/test/types/aedes.test-d.ts @@ -4,6 +4,7 @@ import type { AedesPublishPacket, ConnackPacket, ConnectPacket, PingreqPacket, P import type { AuthenticateError, Brokers, Connection } from 'aedes:server' import Server, { Aedes } from 'aedes:server' +import { IncomingMessage } from 'node:http' import type { Client } from 'aedes:client' import { Socket } from 'node:net' import { expectType } from 'tsd' @@ -124,11 +125,12 @@ expectType(broker.close()) expectType(broker.close(() => {})) // Aedes client -const client = broker.handle({} as Connection) +const client = broker.handle({} as Connection, {} as IncomingMessage) expectType(client) expectType(client.conn) +expectType(client.req!) expectType(client.on('connected', () => {})) expectType(client.on('error', (error: Error) => { diff --git a/types/instance.d.ts b/types/instance.d.ts index dc22b355..c9e757a7 100644 --- a/types/instance.d.ts +++ b/types/instance.d.ts @@ -1,6 +1,7 @@ declare module 'aedes' { import { Duplex } from 'node:stream' import { Socket } from 'node:net' + import { IncomingMessage } from 'http' import { Client } from 'aedes:client' import type { AedesPublishPacket, ConnectPacket, ConnackPacket, Subscription, PingreqPacket, PublishPacket, PubrelPacket } from 'aedes:packet' import { EventEmitter } from 'node:events' @@ -65,7 +66,7 @@ declare module 'aedes' { brokers: Readonly constructor(option?: AedesOptions) - handle: (stream: Connection) => Client + handle: (stream: Connection, request: IncomingMessage) => Client on (event: 'closed', listener: () => void): this on (event: 'client' | 'clientReady' | 'clientDisconnect' | 'keepaliveTimeout', listener: (client: Client) => void): this