Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/lambda/types.d.ts>Handler

A deno runtime for AWS Lambda. Deploy deno via docker, SAM, serverless, or bundle it yourself.
Go to Latest
type alias Handler
import { type Handler } from "https://deno.land/x/lambda@1.45.1/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)) }) }

Type Parameters

optional
TEvent = any
optional
TResult = any
definition: (event: TEvent, context: Context) => Promise<TResult>