refactor: infra folder (#8138)

This commit is contained in:
Jason Rasmussen 2024-03-20 22:15:09 -05:00 committed by GitHub
parent 9fd5d2ad9c
commit 16d0df796c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
139 changed files with 968 additions and 1164 deletions

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;
}
}