Skip to content

Commit cebc3a8

Browse files
lint
1 parent f01c161 commit cebc3a8

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

packages/socket.io-postgres-adapter/lib/adapter.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export interface PostgresAdapterOptions {
5151
*/
5252
export function createAdapter(
5353
pool: Pool,
54-
opts: PostgresAdapterOptions & ClusterAdapterOptions = {}
54+
opts: PostgresAdapterOptions & ClusterAdapterOptions = {},
5555
) {
5656
const options = Object.assign(
5757
{
@@ -61,7 +61,7 @@ export function createAdapter(
6161
cleanupInterval: 30_000,
6262
errorHandler: (err: Error) => debug(err),
6363
},
64-
opts
64+
opts,
6565
);
6666

6767
const namespaces = new Map<string, PostgresAdapter>();
@@ -74,7 +74,7 @@ export function createAdapter(
7474
},
7575
(msg) => {
7676
namespaces.get(msg.nsp)?.onMessage(msg);
77-
}
77+
},
7878
);
7979

8080
return function (nsp: any) {
@@ -112,7 +112,7 @@ export class PostgresAdapter extends ClusterAdapterWithHeartbeat {
112112
constructor(
113113
nsp: any,
114114
opts: ClusterAdapterOptions,
115-
private readonly client: PubSubClient
115+
private readonly client: PubSubClient,
116116
) {
117117
super(nsp, opts);
118118
}
@@ -126,7 +126,7 @@ export class PostgresAdapter extends ClusterAdapterWithHeartbeat {
126126

127127
protected override doPublishResponse(
128128
_requesterUid: ServerId,
129-
response: ClusterResponse
129+
response: ClusterResponse,
130130
) {
131131
return this.client.publish(response);
132132
}

packages/socket.io-postgres-adapter/lib/node-cluster.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function ignoreError() {}
1515

1616
export function setupPrimary(
1717
pool: Pool,
18-
opts: PostgresAdapterOptions & ClusterAdapterOptions = {}
18+
opts: PostgresAdapterOptions & ClusterAdapterOptions = {},
1919
) {
2020
if (!cluster.isPrimary) {
2121
throw "not primary";
@@ -29,7 +29,7 @@ export function setupPrimary(
2929
cleanupInterval: 30_000,
3030
errorHandler: (err: Error) => debug(err),
3131
},
32-
opts
32+
opts,
3333
);
3434

3535
const nodeId = randomId();
@@ -45,7 +45,7 @@ export function setupPrimary(
4545
for (const workerId in cluster.workers) {
4646
cluster.workers[workerId]?.send(msg, ignoreError);
4747
}
48-
}
48+
},
4949
);
5050

5151
cluster.on("message", async (worker, msg: ClusterMessage) => {

packages/socket.io-postgres-adapter/lib/util.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ export class PubSubClient {
6363
private readonly pool: Pool,
6464
private readonly opts: Required<PostgresAdapterOptions>,
6565
private readonly isFromSelf: (msg: ExtendedClusterMessage) => boolean,
66-
private readonly onMessage: (msg: ClusterMessage) => void
66+
private readonly onMessage: (msg: ClusterMessage) => void,
6767
) {
6868
this.initClient().then(() => {}); // ignore error
6969

7070
this.cleanupTimer = setInterval(async () => {
7171
try {
7272
debug("removing old events");
7373
await pool.query(
74-
`DELETE FROM ${opts.tableName} WHERE created_at < now() - interval '${opts.cleanupInterval} milliseconds'`
74+
`DELETE FROM ${opts.tableName} WHERE created_at < now() - interval '${opts.cleanupInterval} milliseconds'`,
7575
);
7676
} catch (err) {
7777
opts.errorHandler(err as Error);
@@ -84,7 +84,7 @@ export class PubSubClient {
8484
debug("reconnection in %d ms", reconnectionDelay);
8585
this.reconnectTimer = setTimeout(
8686
() => this.initClient(),
87-
reconnectionDelay
87+
reconnectionDelay,
8888
);
8989
}
9090

@@ -97,7 +97,7 @@ export class PubSubClient {
9797
client.on("notification", async (msg: Notification) => {
9898
try {
9999
let message = JSON.parse(
100-
msg.payload as string
100+
msg.payload as string,
101101
) as ExtendedClusterMessage;
102102

103103
if (this.isFromSelf(message)) {
@@ -107,10 +107,10 @@ export class PubSubClient {
107107
if (message.attachmentId) {
108108
const result = await this.pool.query(
109109
`SELECT payload FROM ${this.opts.tableName} WHERE id = $1`,
110-
[message.attachmentId]
110+
[message.attachmentId],
111111
);
112112
const fullMessage = decode(
113-
result.rows[0].payload
113+
result.rows[0].payload,
114114
) as ExtendedClusterMessage;
115115
this.onMessage(fullMessage);
116116
} else {
@@ -184,19 +184,19 @@ export class PubSubClient {
184184
}
185185

186186
private async publishWithAttachment(
187-
message: ClusterMessage | ClusterResponse
187+
message: ClusterMessage | ClusterResponse,
188188
) {
189189
const payload = encode(message);
190190
const channel = `${this.opts.channelPrefix}#${message.nsp}`;
191191

192192
debug(
193193
"sending event of type %s with attachment to channel %s",
194194
message.type,
195-
channel
195+
channel,
196196
);
197197
const result = await this.pool.query(
198198
`INSERT INTO ${this.opts.tableName} (payload) VALUES ($1) RETURNING id;`,
199-
[payload]
199+
[payload],
200200
);
201201
const attachmentId = result.rows[0].id;
202202
const headerPayload = JSON.stringify({

0 commit comments

Comments
 (0)