@@ -15,91 +15,89 @@ import { Constants } from './helpers/constants/constants.js';
1515import { requiredEnvironmentVariablesValidator } from './helpers/validators/required-environment-variables.validator.js' ;
1616
1717async function bootstrap ( ) {
18- try {
19- requiredEnvironmentVariablesValidator ( ) ;
20- const appOptions : NestApplicationOptions = {
21- rawBody : true ,
22- logger : new WinstonLogger ( ) ,
23- } ;
24-
25- const app = await NestFactory . create < NestExpressApplication > ( ApplicationModule , appOptions ) ;
26- app . useLogger ( app . get ( WinstonLogger ) ) ;
27- app . set ( 'query parser' , 'extended' ) ;
28-
29- Sentry . init ( {
30- dsn : process . env . SENTRY_DSN ,
31- tracesSampleRate : 1.0 ,
32- } ) ;
33-
34- const globalPrefix = process . env . GLOBAL_PREFIX || '/' ;
35- app . setGlobalPrefix ( globalPrefix ) ;
36-
37- app . useGlobalFilters ( new AllExceptionsFilter ( app . get ( WinstonLogger ) ) ) ;
38-
39- app . use ( helmet ( ) ) ;
40-
41- app . use ( cookieParser ( ) ) ;
42-
43- app . enableCors ( {
44- origin : [
45- 'https://app.autoadmin.org' ,
46- 'http://localhost:4200' ,
47- 'https://app.rocketadmin.org' ,
48- 'https://saas.rocketadmin.com' ,
49- 'https://app-beta.rocketadmin.com' ,
50- Constants . APP_DOMAIN_ADDRESS ,
51- ] ,
52- methods : 'GET,PUT,PATCH,POST,DELETE' ,
53- credentials : true ,
54- preflightContinue : false ,
55- optionsSuccessStatus : 204 ,
56- } ) ;
57-
58- app . use ( cookieParser ( ) ) ;
59-
60- app . use ( bodyParser . json ( { limit : '10mb' } ) ) ;
61- app . use ( bodyParser . urlencoded ( { limit : '10mb' , extended : true } ) ) ;
62-
63- const config = new DocumentBuilder ( )
64- . setTitle ( 'Rocketadmin' )
65- . setDescription ( 'The Rocketadmin API description' )
66- . setVersion ( '1.0' )
67- . addTag ( 'rocketadmin' )
68- . setBasePath ( globalPrefix )
69- . addApiKey ( {
70- type : 'apiKey' ,
71- name : 'x-api-key' ,
72- in : 'header' ,
73- } )
74- . addCookieAuth ( Constants . JWT_COOKIE_KEY_NAME )
75- . build ( ) ;
76- const document = SwaggerModule . createDocument ( app , config ) ;
77- SwaggerModule . setup ( 'docs' , app , document ) ;
78-
79- app . useGlobalPipes (
80- new ValidationPipe ( {
81- exceptionFactory ( validationErrors : ValidationError [ ] = [ ] ) {
82- return new ValidationException ( validationErrors ) ;
83- } ,
84- } ) ,
85- ) ;
86-
87- await app . listen ( 3000 ) ;
88- } catch ( e ) {
89- console . error ( `Failed to initialize, due to ${ e } ` ) ;
90- process . exit ( 1 ) ;
91- }
18+ try {
19+ requiredEnvironmentVariablesValidator ( ) ;
20+ const appOptions : NestApplicationOptions = {
21+ rawBody : true ,
22+ logger : new WinstonLogger ( ) ,
23+ } ;
24+
25+ const app = await NestFactory . create < NestExpressApplication > ( ApplicationModule , appOptions ) ;
26+ app . useLogger ( app . get ( WinstonLogger ) ) ;
27+ app . set ( 'query parser' , 'extended' ) ;
28+
29+ Sentry . init ( {
30+ dsn : process . env . SENTRY_DSN ,
31+ tracesSampleRate : 1.0 ,
32+ } ) ;
33+
34+ const globalPrefix = process . env . GLOBAL_PREFIX || '/' ;
35+ app . setGlobalPrefix ( globalPrefix ) ;
36+
37+ app . useGlobalFilters ( new AllExceptionsFilter ( app . get ( WinstonLogger ) ) ) ;
38+
39+ app . use ( helmet ( ) ) ;
40+
41+ app . enableCors ( {
42+ origin : [
43+ 'https://app.autoadmin.org' ,
44+ 'http://localhost:4200' ,
45+ 'https://app.rocketadmin.org' ,
46+ 'https://saas.rocketadmin.com' ,
47+ 'https://app-beta.rocketadmin.com' ,
48+ Constants . APP_DOMAIN_ADDRESS ,
49+ ] ,
50+ methods : 'GET,PUT,PATCH,POST,DELETE' ,
51+ credentials : true ,
52+ preflightContinue : false ,
53+ optionsSuccessStatus : 204 ,
54+ } ) ;
55+
56+ app . use ( cookieParser ( ) ) ;
57+
58+ app . use ( bodyParser . json ( { limit : '10mb' } ) ) ;
59+ app . use ( bodyParser . urlencoded ( { limit : '10mb' , extended : true } ) ) ;
60+
61+ const config = new DocumentBuilder ( )
62+ . setTitle ( 'Rocketadmin' )
63+ . setDescription ( 'The Rocketadmin API description' )
64+ . setVersion ( '1.0' )
65+ . addTag ( 'rocketadmin' )
66+ . setBasePath ( globalPrefix )
67+ . addApiKey ( {
68+ type : 'apiKey' ,
69+ name : 'x-api-key' ,
70+ in : 'header' ,
71+ } )
72+ . addCookieAuth ( Constants . JWT_COOKIE_KEY_NAME )
73+ . build ( ) ;
74+ const document = SwaggerModule . createDocument ( app , config ) ;
75+ SwaggerModule . setup ( 'docs' , app , document ) ;
76+
77+ app . useGlobalPipes (
78+ new ValidationPipe ( {
79+ exceptionFactory ( validationErrors : ValidationError [ ] = [ ] ) {
80+ return new ValidationException ( validationErrors ) ;
81+ } ,
82+ } ) ,
83+ ) ;
84+
85+ await app . listen ( 3000 ) ;
86+ } catch ( e ) {
87+ console . error ( `Failed to initialize, due to ${ e } ` ) ;
88+ process . exit ( 1 ) ;
89+ }
9290}
9391
9492const temp = process . exit ;
9593
9694process . exit = ( ) => {
97- console . trace ( ) ;
98- process . exit = temp ;
99- process . exit ( ) ;
95+ console . trace ( ) ;
96+ process . exit = temp ;
97+ process . exit ( ) ;
10098} ;
10199
102100bootstrap ( ) . catch ( ( e ) => {
103- console . error ( `Bootstrap promise failed with error: ${ e } ` ) ;
104- process . exit ( 1 ) ;
101+ console . error ( `Bootstrap promise failed with error: ${ e } ` ) ;
102+ process . exit ( 1 ) ;
105103} ) ;
0 commit comments