hono-adapter-aws-lambda is a fork of hono's aws-lambda
adapter, experimenting and adding some extra features
- Codebase is refactored quite a bit.
- Add routing support for trigger events.
-
I.e, support for S3, SQS, etc. triggers, which would also support a simpler cross-function call interface.
- Multiple routes on the same eventSource support.
- Uses a factory pattern, the internal trigger context (middlewares, env bindings) is decoupled from the main Hono app.
- See #10 for more information.
-
- Support returning a Lambda response result directly, useful for returning the response of another invoked function.
# pnpm (recommended)
pnpm install hono-adapter-aws-lambda
// ESM
import { handle, streamHandle } from 'hono-adapter-aws-lambda'
Fast example of accepting an S3 trigger event
import type { S3Event } from 'aws-lambda' // You need to install `@types/aws-lambda`
import { createTriggerFactory, handle, streamHandle } from 'hono-adapter-aws-lambda'
interface Bindings {
event: { Records: Array<{ eventName: string }> }
}
const app = new Hono<{ Bindings: Bindings }>()
const triggerFactory = createTriggerFactory(app)
triggerFactory.on('aws:s3', '$!', c => c.text((c.env.event as S3Event).Records[0].eventName))
See some more examples in the test file: test/index.test.ts