Skip to content

Commit

Permalink
fix(deploy): app initialization on lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielaraujof committed Jul 6, 2023
1 parent 27f0e46 commit 974b8e3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/app.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ import { AppModule } from './app.module';
export const createApp = async () => {
const app = await NestFactory.create<
NestFastifyApplication<RawServerDefault>
>(AppModule, new FastifyAdapter());
>(
AppModule,
new FastifyAdapter({
logger: true,
}),
);

return app;
};
Expand Down
12 changes: 8 additions & 4 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ import { AppService } from './app.service';
isGlobal: true,
load: [graphQLConfig],
}),
GraphQLModule.forRoot<ApolloDriverConfig>({
GraphQLModule.forRootAsync<ApolloDriverConfig>({
imports: [ConfigModule],
driver: ApolloDriver,
playground: true,
autoSchemaFile: true,
sortSchema: true,
useFactory: (config: ConfigType<typeof graphQLConfig>) => ({
playground: config.playgroundEnabled,
autoSchemaFile: true,
sortSchema: true,
}),
inject: [graphQLConfig.KEY],
}),
],
providers: [AppService, AppResolver],
Expand Down
1 change: 1 addition & 0 deletions src/serverless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ let server: Handler;

async function bootstrap(): Promise<Handler> {
const app = await createApp();
app.init();
const fastifyApp = app.getHttpAdapter().getInstance();
return awsLambdaFastify(fastifyApp as any);
}
Expand Down

0 comments on commit 974b8e3

Please sign in to comment.