chore: websocket

This commit is contained in:
mahyargdz
2025-07-10 15:45:26 +03:30
parent a761dc1718
commit 6933646a0e
18 changed files with 2104 additions and 42 deletions
+7
View File
@@ -3,6 +3,7 @@ import { Logger, ValidationPipe } from "@nestjs/common";
import { ConfigService } from "@nestjs/config";
import { NestFactory } from "@nestjs/core";
import { FastifyAdapter, NestFastifyApplication } from "@nestjs/platform-fastify";
import { IoAdapter } from "@nestjs/platform-socket.io";
import { AppModule } from "./app.module";
import { getSwaggerDocument } from "./configs/swagger.config";
@@ -25,6 +26,9 @@ async function bootstrap() {
const app = await NestFactory.create<NestFastifyApplication>(AppModule, fastifyAdapter);
// Setup WebSocket adapter
app.useWebSocketAdapter(new IoAdapter(app));
app.useGlobalPipes(new ValidationPipe({ transform: true, whitelist: true, forbidNonWhitelisted: true }));
app.useGlobalInterceptors(new ResponseInterceptor(), new PaginationInterceptor());
@@ -37,6 +41,7 @@ async function bootstrap() {
credentials: true,
optionsSuccessStatus: 204,
});
const configService = app.get<ConfigService>(ConfigService);
getSwaggerDocument(app);
@@ -51,8 +56,10 @@ async function bootstrap() {
await app.listen(PORT, "0.0.0.0", () => {
logger.log(`Application is running on: http://localhost:${PORT}`);
logger.log(`Swagger documentation: http://localhost:${PORT}/api-docs`);
logger.log(`WebSocket server is running on: ws://localhost:${PORT}/email`);
});
}
bootstrap().catch((error) => {
const logger = new Logger("Bootstrap");
logger.error("Failed to start application", error);