From 974b8e39bb92d1a5443ac03e7956230311733d7e Mon Sep 17 00:00:00 2001 From: Gabriel Araujo Date: Wed, 5 Jul 2023 21:42:57 -0300 Subject: [PATCH] fix(deploy): app initialization on lambda --- src/app.factory.ts | 7 ++++++- src/app.module.ts | 12 ++++++++---- src/serverless.ts | 1 + 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/app.factory.ts b/src/app.factory.ts index 67d2038..51b7fef 100644 --- a/src/app.factory.ts +++ b/src/app.factory.ts @@ -11,7 +11,12 @@ import { AppModule } from './app.module'; export const createApp = async () => { const app = await NestFactory.create< NestFastifyApplication - >(AppModule, new FastifyAdapter()); + >( + AppModule, + new FastifyAdapter({ + logger: true, + }), + ); return app; }; diff --git a/src/app.module.ts b/src/app.module.ts index 31536f5..612c433 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -14,11 +14,15 @@ import { AppService } from './app.service'; isGlobal: true, load: [graphQLConfig], }), - GraphQLModule.forRoot({ + GraphQLModule.forRootAsync({ + imports: [ConfigModule], driver: ApolloDriver, - playground: true, - autoSchemaFile: true, - sortSchema: true, + useFactory: (config: ConfigType) => ({ + playground: config.playgroundEnabled, + autoSchemaFile: true, + sortSchema: true, + }), + inject: [graphQLConfig.KEY], }), ], providers: [AppService, AppResolver], diff --git a/src/serverless.ts b/src/serverless.ts index f116a4c..ef8fb29 100644 --- a/src/serverless.ts +++ b/src/serverless.ts @@ -7,6 +7,7 @@ let server: Handler; async function bootstrap(): Promise { const app = await createApp(); + app.init(); const fastifyApp = app.getHttpAdapter().getInstance(); return awsLambdaFastify(fastifyApp as any); }