简体   繁体   English

如何使用 fastify + nestjs + firebase 函数

[英]How to use fastify + nestjs + firebase functions

I am using NestJS and Cloud Functions, because of performance I want to switch to Fastify.我正在使用 NestJS 和 Cloud Functions,因为性能我想切换到 Fastify。

But I have no idea what to pass to functions.https.onRequest(???)但我不知道要传递给functions.https.onRequest(???)

My old code for express is:我的旧快递代码是:

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);

And new code is:新代码是:

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 https://docs.nestjs.com/techniques/performance

You will need to create an anonymous function to pass as an argument as specified in here[1].您将需要创建一个匿名函数作为此处指定的参数传递 [1]。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用云功能以使用 Firebase 云视觉 - How to use the Cloud Functions in order to use Firebase Cloud vision 用于 firebase 函数的 NestJS:开始时间是否适合生产? - NestJS for firebase functions: are the start times production-suitable? NestJS Fastify - 在 S3 上上传文件的最佳方式 - NestJS Fastify - Best way to upload file on S3 如何在 netlify lamda 中使用 firebase 云函数的 firestore.onWrite() - How to use firebase cloud functions' firestore.onWrite() in netlify lamda 如何将 Firebase 参数化配置与 Typescript 一起用于 Cloud Functions? - How can I use Firebase Parameterized configuration with Typescript for Cloud Functions? 在 Firebase 函数中使用 Map 的问题 - Problem to use a Map in Firebase Functions 如何在 firebase 中排队函数 - How to enqueue functions in firebase 如何将 TS 路径映射与 Firebase 云函数一起使用 - How to use TS Path Mapping with Firebase Cloud Functions 如何在 Firebase Cloud Functions 中对 npm 模块使用 `import`? - How do I use `import` for npm modules in Firebase Cloud Functions? 如何在 firebase 云函数上正确使用 express-session - How to properly use express-session on firebase cloud functions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM