feat(server): use postgres-adapter for websockets (#5569)

* feat(server): use postgres-adapter for websockets

* refactor: create attachment table via migration
This commit is contained in:
Jason Rasmussen
2023-12-08 20:38:25 -05:00
committed by GitHub
parent a426ea8fbc
commit 92b4284b5a
8 changed files with 213 additions and 68 deletions
+19
View File
@@ -0,0 +1,19 @@
import { INestApplicationContext } from '@nestjs/common';
import { IoAdapter } from '@nestjs/platform-socket.io';
import { createAdapter } from '@socket.io/postgres-adapter';
import { ServerOptions } from 'socket.io';
import { DataSource } from 'typeorm';
import { PostgresDriver } from 'typeorm/driver/postgres/PostgresDriver.js';
export class WebSocketAdapter extends IoAdapter {
constructor(private app: INestApplicationContext) {
super(app);
}
createIOServer(port: number, options?: ServerOptions): any {
const server = super.createIOServer(port, options);
const pool = (this.app.get(DataSource).driver as PostgresDriver).master;
server.adapter(createAdapter(pool));
return server;
}
}