import { type Handler } from "https://deno.land/x/lambda@1.42.2/types.d.ts";
The interface that AWS Lambda will invoke your handler with. There are more specialized types for many cases where AWS services invoke your lambda, but you can directly use this type for when you are invoking your lambda directly.
See tme AWS documentation for more information about the runtime behavior, and the AWS Blog post introducing the async handler behavior in the 8.10 runtime.
Examples
interface NameEvent { fullName: string } interface NameResult { firstName: string middleNames: string lastName: string } type PersonHandler = Handler<NameEvent, NameResult>
export const handler: PersonHandler = async (event) => { const names = event.fullName.split(' ') const firstName = names.shift() const lastName = names.pop() return { firstName, middleNames: names, lastName } }
export const handler: Handler = async (event, context) => { console.log("EVENT: \n" + JSON.stringify(event, null, 2)) return context.logStreamName }
const s3 = new AWS.S3()
export const handler: Handler = async (event) => { const response = await s3.listBuckets().promise() return response?.Buckets.map((bucket) => bucket.Name) }
let url = "https://docs.aws.amazon.com/lambda/latest/dg/welcome.html"
export const handler: Handler<void, number> = (event, context, callback) => { https.get(url, (res) => { callback(null, res.statusCode) }).on('error', (e) => { callback(Error(e)) }) }