MCPcopy Create free account
hub / github.com/apitable/apitable / bootstrap

Function bootstrap

packages/room-server/src/main.ts:36–91  ·  view source on GitHub ↗

* entrance method

()

Source from the content-addressed store, hash-verified

34 * entrance method
35 */
36async 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
93void bootstrap();

Callers 1

main.tsFile · 0.85

Calls 12

initFastifyFunction · 0.90
initRedisIoAdapterFunction · 0.90
initSwaggerFunction · 0.90
initHttpHookFunction · 0.90
initSentryFunction · 0.90
initRoomGrpcFunction · 0.90
initSocketGrpcFunction · 0.90
initHocuspocusFunction · 0.90
getMethod · 0.65
selectMethod · 0.65
logMethod · 0.45
getUrlMethod · 0.45

Tested by

no test coverage detected