import { useContainer } from 'class-validator' ; import { text } from 'express' ; import * as helmet from 'helmet' ; import { NestFactory } from '@nestjs/core' ; import { NestExpressApplication } from '@nestjs/platform-express' ; import { AppConfig } from '@fc/app' ; import { BridgeHttpProxyConfig } from '@fc/bridge-http-proxy' ; import { ConfigService } from '@fc/config' ; import { LoggerService } from '@fc/logger' ; import { AppModule } from './app.module' ; import config from './config' ; async function bootstrap ( ) { const configService = new ConfigService ( { config , schema : BridgeHttpProxyConfig , } ) ; const { urlPrefix , httpsOptions : { key , cert } , } = configService . get < AppConfig > ( 'App' ) ; const appModule = AppModule . forRoot ( configService ) ; const httpsOptions = key && cert ? { key , cert } : null ; const app = await NestFactory . create < NestExpressApplication > ( appModule , { see https see https see https bodyParser : false , httpsOptions , } ) ; see https see https app . set ( 'query parser' , 'simple' ) ; app . setGlobalPrefix ( urlPrefix ) ; see https app . use ( helmet ( ) ) ; app . use ( helmet . contentSecurityPolicy ( { directives : { defaultSrc : [ "'self'" ] , TODO see https styleSrc : [ "'self'" ] , scriptSrc : [ "'self'" ] , } , } ) ) ; app . use ( helmet . permittedCrossDomainPolicies ( ) ) ; see body-parser . md app . use ( text ( { type : 'application/x-www-form-urlencoded' } ) ) ; const logger = await app . resolve ( LoggerService ) ; app . useLogger ( logger ) ; see https see https see https useContainer ( app . select ( appModule ) , { fallbackOnErrors : true } ) ; await app . listen ( 3000 ) ; } bootstrap ( ) ;