【发布时间】:2021-07-04 08:52:56
【问题描述】:
我正在切换到新的 Node AWS SDK (v3) 以利用其模块化和 Typescript 支持。我需要做的第一件事是编写一个 Lambda 函数,但我找不到支持处理函数签名的类型。 @aws/client-lambda 中的类型似乎都与管理 Lambda 的客户端有关。
Node SDK 是否有用于在某处编写 Lambda 的官方类型?特别是:
-
context参数的类型在哪里? - 对于
event参数,是否有可能来自其他 AWS 服务及其相应类型的事件列表?
interface Event {
// This could be anything -- a custom structure or something
// created by another AWS service, so it makes sense that
// there isn't a discoverable type for this. There should be
// corresponding types for each service that can send events
// to Lambda functions though. Where are these?
}
interface Context {
// This is provided by Lambda, but I can't find types for it anywhere.
// Since it's always the same, there should be a type defined somewhere,
// but where?
}
exports.handler = ( event: Event, context: Context )=>{
// While `event` could anything so it makes sense to not have a single type available,
// `context` is always the same thing and should have a type somewhere.
}
【问题讨论】:
标签: node.js typescript aws-lambda aws-sdk-js aws-sdk-js-v3