* entrance method
()
| 34 | * entrance method |
| 35 | */ |
| 36 | async function bootstrap() { |
| 37 | immer.setAutoFreeze(false); |
| 38 | |
| 39 | const fastifyAdapter = await initFastify(); |
| 40 | |
| 41 | const app = await NestFactory.create<NestFastifyApplication>(AppModule, fastifyAdapter); |
| 42 | |
| 43 | const logger = app.get<LoggerService>(WINSTON_MODULE_NEST_PROVIDER); |
| 44 | app.useLogger(logger); |
| 45 | |
| 46 | initRedisIoAdapter(app); |
| 47 | initSwagger(app); |
| 48 | initHttpHook(app); |
| 49 | initSentry(app); |
| 50 | |
| 51 | // express performance traces |
| 52 | // app.use(Sentry.Handlers.requestHandler()); |
| 53 | |
| 54 | // global exception filter |
| 55 | app.useGlobalFilters(new GlobalExceptionFilter(app.get<I18nService>(I18nService))); |
| 56 | |
| 57 | // tracing all the requests by sentry |
| 58 | // app.useGlobalInterceptors(new TracingHandlerInterceptor()); |
| 59 | |
| 60 | // global intercept with standard format |
| 61 | app.useGlobalInterceptors(new HttpResponseInterceptor()); |
| 62 | |
| 63 | // global pipes for custom validation |
| 64 | app.useGlobalPipes( |
| 65 | new ValidationPipe({ |
| 66 | transform: true, |
| 67 | stopAtFirstError: true, |
| 68 | forbidUnknownValues: false, |
| 69 | }), |
| 70 | ); |
| 71 | |
| 72 | // enable shutdown hooks |
| 73 | app.enableShutdownHooks(); |
| 74 | |
| 75 | // grpc |
| 76 | initRoomGrpc(logger, app); |
| 77 | initSocketGrpc(logger, app); |
| 78 | |
| 79 | initHocuspocus(app); |
| 80 | |
| 81 | await app.startAllMicroservices(); |
| 82 | // eslint-disable-next-line react-hooks/rules-of-hooks |
| 83 | useContainer(app.select(AppModule), { fallbackOnErrors: true }); |
| 84 | // listening port |
| 85 | await app.listen(BootstrapConstants.SERVER_PORT, '0.0.0.0'); |
| 86 | |
| 87 | // print running environment |
| 88 | logger.log(`Application[${APPLICATION_NAME}]-Env[${environment}]`, 'Bootstrap'); |
| 89 | // print server info |
| 90 | logger.log(`The service is running, please visit it: [ ${await app.getUrl()} ]`, 'Bootstrap'); |
| 91 | } |
| 92 | |
| 93 | void bootstrap(); |
no test coverage detected