Skip to content

Instantly share code, notes, and snippets.

@imflamboyant
Created May 4, 2022 08:59
Show Gist options
  • Select an option

  • Save imflamboyant/1cb88bb3491bee1d648b8bc86eb0ec27 to your computer and use it in GitHub Desktop.

Select an option

Save imflamboyant/1cb88bb3491bee1d648b8bc86eb0ec27 to your computer and use it in GitHub Desktop.
import { configure as serverlessExpress } from '@vendia/serverless-express';
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
let cachedServer;
export const handler = async (event, context) => {
if (!cachedServer) {
const nestApp = await NestFactory.create(AppModule);
await nestApp.init();
cachedServer = serverlessExpress({ app: nestApp.getHttpAdapter().getInstance() });
}
return cachedServer(event, context);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment