firebase-functions package

API รุ่นที่ 2 สำหรับ Cloud Functions for Firebase SDK นี้รองรับการนำเข้าเชิงลึก ตัวอย่างเช่น Namespace pubsub จะมีอยู่ที่ firebase-functions/v2 หรือนำเข้าได้จาก firebase-functions/v2/pubsub โดยตรง

ฟังก์ชัน

ฟังก์ชัน คำอธิบาย
setGlobalOptions(ตัวเลือก) ตั้งค่าตัวเลือกเริ่มต้นสำหรับฟังก์ชันทั้งหมดที่เขียนโดยใช้ SDK รุ่นที่ 2

ชั้นเรียน

ชั้น คำอธิบาย
เปลี่ยน อินเทอร์เฟซ Cloud Functions สำหรับเหตุการณ์ที่เปลี่ยนสถานะ เช่น Realtime Database หรือ Cloud Firestore onWrite และเหตุการณ์ onUpdateดูข้อมูลเพิ่มเติมเกี่ยวกับรูปแบบที่ใช้สร้างออบเจ็กต์ Change ได้ที่ด้านล่าง

อินเทอร์เฟซ

อินเทอร์เฟซ คำอธิบาย
CloudEvent (เบต้า) CloudEventBase คือฐานของรูปแบบข้ามแพลตฟอร์มสำหรับการเข้ารหัสเหตุการณ์แบบ Serverless ดูข้อมูลเพิ่มเติมได้ที่ https://github.com/cloudevents/spec
CloudFunction (เบต้า) เครื่องจัดการสำหรับ CloudEvents
EventHandlerOptions ช่องเพิ่มเติมที่ตั้งค่าในฟังก์ชันการจัดการเหตุการณ์ใดก็ได้
ตัวเลือกทั่วโลก GlobalOptions เป็นตัวเลือกที่ตั้งค่าทั่วทั้งโปรเจ็กต์ได้ ตัวเลือกเหล่านี้มีการใช้งานทั่วไปใน HTTPS และฟังก์ชันการจัดการเหตุการณ์

เนมสเปซ

พิมพ์ชื่อแทน

พิมพ์ชื่อแทน คำอธิบาย
การตั้งค่าขาเข้า รายการตัวเลือกที่ใช้ได้กับ IngressSettings
ตัวเลือกหน่วยความจำ รายการตัวเลือกหน่วยความจำที่ใช้ได้ซึ่ง Cloud Functions รองรับ
ParamsOf ประเภทที่แมปพารามิเตอร์แคปเจอร์กรุ๊สทั้งหมดเข้ากับคีย์ของระเบียน เช่น ParamsOf<"users/{uid}"> คือ { uid: string } ParamsOf<"users/{uid}/logs/{log}"> เป็น { uid: string; log: string } ParamsOf<"some/static/data"> คือ {}ด้วยเหตุผลด้านความยืดหยุ่น ParamsOf จึงเป็น Record<string, string>
ภูมิภาคที่รองรับ รายชื่อภูมิภาคทั้งหมดที่ Cloud Functions (รุ่นที่ 2) รองรับ
VpcEgressSetting รายการตัวเลือกที่ใช้ได้กับ VpcConnectorEgressSettings

setGlobalOptions()

ตั้งค่าตัวเลือกเริ่มต้นสำหรับฟังก์ชันทั้งหมดที่เขียนโดยใช้ SDK รุ่นที่ 2

ลายเซ็น:

export declare function setGlobalOptions(options: GlobalOptions): void;

พารามิเตอร์

พารามิเตอร์ ประเภท คำอธิบาย
ตัวเลือก ตัวเลือกทั่วโลก ตัวเลือกในการตั้งเป็นค่าเริ่มต้น

การคืนสินค้า:

เป็นโมฆะ

การตั้งค่าขาเข้า

รายการตัวเลือกที่ใช้ได้กับ IngressSettings

ลายเซ็น:

export type IngressSetting = "ALLOW_ALL" | "ALLOW_INTERNAL_ONLY" | "ALLOW_INTERNAL_AND_GCLB";

ตัวเลือกหน่วยความจำ

รายการตัวเลือกหน่วยความจำที่ใช้ได้ซึ่ง Cloud Functions รองรับ

ลายเซ็น:

export type MemoryOption = "128MiB" | "256MiB" | "512MiB" | "1GiB" | "2GiB" | "4GiB" | "8GiB" | "16GiB" | "32GiB";

พารามิเตอร์

ประเภทที่แมปพารามิเตอร์แคปเจอร์กรุ๊สทั้งหมดเข้ากับคีย์ของระเบียน เช่น ParamsOf<"users/{uid}"> คือ { uid: string } ParamsOf<"users/{uid}/logs/{log}"> เป็น { uid: string; log: string } ParamsOf<"some/static/data"> เท่ากับ {}

ด้วยเหตุผลด้านความยืดหยุ่น ParamsOf คือ Record<string, string>

ลายเซ็น:

export type ParamsOf<PathPattern extends string> = string extends PathPattern ? Record<string, string> : {
    [Key in Extract<Split<NullSafe<PathPattern>, "/">[number]>]: string;
};

ภูมิภาคที่รองรับ

รายชื่อภูมิภาคทั้งหมดที่ Cloud Functions (รุ่นที่ 2) รองรับ

ลายเซ็น:

export type SupportedRegion = "asia-east1" | "asia-northeast1" | "asia-northeast2" | "europe-north1" | "europe-west1" | "europe-west4" | "us-central1" | "us-east1" | "us-east4" | "us-west1" | "asia-east2" | "asia-northeast3" | "asia-southeast1" | "asia-southeast2" | "asia-south1" | "australia-southeast1" | "europe-central2" | "europe-west2" | "europe-west3" | "europe-west6" | "northamerica-northeast1" | "southamerica-east1" | "us-west2" | "us-west3" | "us-west4";

การตั้งค่า VpcEgress

รายการตัวเลือกที่ใช้ได้กับ VpcConnectorEgressSettings

ลายเซ็น:

export type VpcEgressSetting = "PRIVATE_RANGES_ONLY" | "ALL_TRAFFIC";