mirror of
https://github.com/immich-app/immich.git
synced 2025-12-02 16:39:56 +09:00
refactor: infra folder (#8138)
This commit is contained in:
19
server/src/middleware/websocket.adapter.ts
Normal file
19
server/src/middleware/websocket.adapter.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user