import { NestFactory } from '@nestjs/core' ; import { AppModule } from './app.module' ; import cookieParser from 'cookie-parser' ; import { ConfigService } from '@nestjs/config' ; import { config } from 'aws-sdk' ; import { Callback , Context , Handler } from 'aws-lambda' ; import serverlessExpress from '@vendia/serverless-express' ; let server ; async function bootstrap ( ) { const app = await NestFactory . create ( AppModule ) ; const configService = app . get ( ConfigService ) ; app . enableCors ( { credentials : true , origin : configService . get ( 'CLIENT_HOST' ) , } ) ; app . use ( cookieParser ( ) ) ; config . update ( { region : 'ap-northeast-2' , } ) ; app . init ( ) ; const expressApp = app . getHttpAdapter ( ) . getInstance ( ) ; return serverlessExpress ( { app : expressApp } ) ; } export const handler = async ( event , context , callback ) => { server = server ?? ( await bootstrap ( ) ) ; return server ( event , context , callback ) ; } ;