1
1
import { Adapter, BroadcastOptions, Room } from "socket.io-adapter";
2
2
import { randomBytes } from "crypto";
3
3
import { encode, decode } from "@msgpack/msgpack";
4
+ import { Pool } from "pg";
4
5
5
6
const randomId = () => randomBytes(8).toString("hex");
6
7
const debug = require("debug")("socket.io-postgres-adapter");
@@ -118,7 +119,7 @@ export interface PostgresAdapterOptions {
118
119
* @public
119
120
*/
120
121
export function createAdapter(
121
- pool: any ,
122
+ pool: Pool ,
122
123
opts: Partial<PostgresAdapterOptions> = {}
123
124
) {
124
125
return function (nsp: any) {
@@ -136,7 +137,7 @@ export class PostgresAdapter extends Adapter {
136
137
public payloadThreshold: number;
137
138
public cleanupInterval: number;
138
139
139
- private readonly pool: any ;
140
+ private readonly pool: Pool ;
140
141
private client: any;
141
142
private nodesMap: Map<string, number> = new Map<string, number>(); // uid => timestamp of last message
142
143
private heartbeatTimer: NodeJS.Timeout | undefined;
@@ -152,7 +153,11 @@ export class PostgresAdapter extends Adapter {
152
153
*
153
154
* @public
154
155
*/
155
- constructor(nsp: any, pool: any, opts: Partial<PostgresAdapterOptions> = {}) {
156
+ constructor(
157
+ nsp: any,
158
+ pool: Pool,
159
+ opts: Partial<PostgresAdapterOptions> = {}
160
+ ) {
156
161
super(nsp);
157
162
this.pool = pool;
158
163
this.uid = opts.uid || randomId();
0 commit comments