更改 v2 中可调用的 firebase 云函数的区域

Change region of firebase cloud functions of callable in v2

嘿,所以我正在尝试升级到 firebase 云函数的 v2,但是在尝试更改代码时,我注意到我的函数不再像 v1 中那样具有 .region。

这是我可以调用 .region 并更改它的 v1 版本

import * as functions from "firebase-functions";

exports.helloWorld = functions.region("europe-west1").https.onCall(() => {
  functions.logger.info("Hello logs!", { structuredData: true });

  return { text: "Hello from Firebase!" };
});

现在我升级到 v2,但我得到:

Property 'region' does not exist on type 
'typeof import("/.../node_modules/firebase-functions/lib/v2/index")

尝试为 firebase 云函数 v2 实现类似的功能有什么想法吗?

import { https, logger } from "firebase-functions/v2";
import * as functions from "firebase-functions/v2";

// // Start writing Firebase Functions
// // https://firebase.google.com/docs/functions/typescript
//

const regionalFunctions = functions.region("europe-west1");

exports.helloWorld = regionalFunctions.https.onCall(() => {
  logger.info("Hello logs!", { structuredData: true });

  return { text: "Hello ${process.env.PLANET} and ${process.env.AUDIENCE}" };
});

您可以在函数的选项中指定region,如下所示:

import { onCall } from "firebase-functions/v2/https";

export const testFunction = onCall({ region: "..." }, (event) => {
  // ...
})