0

我正在使用 NestJS 和 Cloud Functions,因为性能原因我想切换到 Fastify。

但我不知道要传递给什么functions.https.onRequest(???)

我的快递旧代码是:

admin.initializeApp(functions.config().firebase);

const server: express.Express = express();

const startNestApplication = async (expressInstance: express.Express) => {
  const adapter = new ExpressAdapter(expressInstance);
  const app = await NestFactory.create(AppModule, adapter, {});
  app.enableCors();
  await app.init();
  return app;
};

const main = startNestApplication(server);

export const api = functions.https.onRequest(server);

新代码是:

admin.initializeApp(functions.config().firebase);

const startNestApplication = async () => {
  const adapter = new FastifyAdapter();
  const app = await NestFactory.create<NestFastifyApplication>(AppModule, adapter, {});
  app.enableCors();
  await app.init();
  return app;
};

const main = startNestApplication();

export const api = functions.https.onRequest(???);

https://docs.nestjs.com/techniques/performance

4

1 回答 1

0

您将需要创建一个匿名函数以作为此处[1] 中指定的参数传递。

[1] https://firebase.google.com/docs/functions/http-events

于 2020-01-30T00:09:54.883 回答