Hono environment type that extends Env
Configuration options for DynamoDB client
Hono middleware that sets DynamoDB instances
import { Hono } from 'hono';
import { dynamoDBMiddleware, Env } from '@squilla/hono-aws-middlewares';
const app = new Hono<Env>();
// Set up middleware
app.use('*', dynamoDBMiddleware({
region: 'ap-northeast-1'
}));
// Use DynamoDB
app.get('/users/:id', async (c) => {
const dynamoDB = c.get('DynamoDB');
const result = await dynamoDB.getItem({
TableName: 'Users',
Key: { id: { S: c.req.param('id') } }
});
return c.json(result.Item);
});
DynamoDB middleware for Hono
Creates AWS SDK v3 DynamoDB and DynamoDBClient instances and sets them in the Hono context to generate middleware.