File size: 568 Bytes
f78b36a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { NestFactory } from '@nestjs/core';
import { ExpressAdapter } from '@nestjs/platform-express';
import { AppModule } from './app.module';
import { setupGlobalMiddleware } from './setup';
import express from 'express';

const expressApp = express();

let app: any;

const bootstrap = async () => {
  if (!app) {
    app = await NestFactory.create(AppModule, new ExpressAdapter(expressApp));
    setupGlobalMiddleware(app);
    await app.init();
  }
  return app;
};

export default async (req: any, res: any) => {
  await bootstrap();
  expressApp(req, res);
};