[英]TypeScript types with Google Cloud Functions and Cloud Events
I'm using TypeScript to write some Cloud Functions (Gen 2) in GCP that are triggered by a PubSub message.我正在使用 TypeScript 在 GCP 中编写一些由 PubSub 消息触发的 Cloud Functions(第 2 代)。 Right now my code looks like this:
现在我的代码看起来像这样:
import { CloudEvent, cloudEvent } from "@google-cloud/functions-framework"
interface PubsubMessageSentData {
message: {
data: string
}
}
cloudEvent("test", async (cloudEvent: CloudEvent<PubsubMessageSentData>) => {
console.log("Data:", cloudEvent.data?.messgae.data)
})
I'm wondering if there's a type like PubsubMessageSentData
defined by google somehwere so I don't have to rely on the interface I've written myself.我想知道是否有像
PubsubMessageSentData
这样由 google somehwere 定义的类型,所以我不必依赖我自己编写的接口。
I'd expect there to be a type I can use to easily use as a type argument for CloudEvent<>
我希望有一种类型可以轻松用作
CloudEvent<>
的类型参数
I've found the types I'm looking for -我找到了我要找的类型 -
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.