Skip to content

Commit

Permalink
fix(typings): properly expose the createAdapter method
Browse files Browse the repository at this point in the history
  • Loading branch information
darrachequesne committed Nov 14, 2020
1 parent 3334d99 commit 0d2d69c
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { Adapter, BroadcastOptions, Room, SocketId } from "socket.io-adapter";

const debug = require("debug")("socket.io-redis");

module.exports = exports = createAdapter;

/**
* Request types, for messages between nodes
*/
Expand All @@ -27,9 +29,23 @@ interface Request {
}

export interface RedisAdapterOptions {
/**
* the name of the key to pub/sub events on as prefix
* @default socket.io
*/
key: string;
/**
* the redis client to publish events on
*/
pubClient: any;
/**
* the redis client to subscribe to events on
*/
subClient: any;
/**
* after this timeout the adapter will stop waiting from responses to request
* @default 5000
*/
requestsTimeout: number;
}

Expand All @@ -52,8 +68,9 @@ function createRedisClient(uri, opts) {
* @public
*/
export function createAdapter(uri: string, opts?: Partial<RedisAdapterOptions>);
export function createAdapter(opts: Partial<RedisAdapterOptions>);
export function createAdapter(
uri?: string,
uri?: any,
opts: Partial<RedisAdapterOptions> = {}
) {
// handle options only
Expand Down Expand Up @@ -606,5 +623,3 @@ export class RedisAdapter extends Adapter {
}
}
}

module.exports = createAdapter;

0 comments on commit 0d2d69c

Please sign in to comment.