Hono DynamoDB Middleware - v1.1.1
    Preparing search index...

    Function dynamoDBMiddleware

    • DynamoDB middleware for Hono

      Creates AWS SDK v3 DynamoDB and DynamoDBClient instances and sets them in the Hono context to generate middleware.

      Type Parameters

      • E extends Env

        Hono environment type that extends Env

      Parameters

      • config: DynamoDBClientConfig = {}

        Configuration options for DynamoDB client

      Returns MiddlewareHandler<E>

      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);
      });

      1.0.0