This repository is an example of using AWS CDK to build an API Gateway and Lambda function with Hono.
This project demonstrates how to use the Hono web framework with AWS Lambda and API Gateway, utilizing AWS CDK for infrastructure as code.
-
Clone the repository:
git clone https://github.com/ve1997/hono-on-aws-lambda.git cd hono-on-aws-lambda
-
Install dependencies
npm install
lib/
: Contains the AWS CDK stack definitionlambda/
: Contains the Hono application codetypes/
: This includes exporting the AppType which is necessary when creating the Hono client object in the client repositorytest/
: Contains tests for the Hono application
- Synthesize the CloudFormation template
cdk synth
- Deploy the stack
cdk deploy
Run the tests using Vitest
npm run test
The following endpoints are available once the stack is deployed:
GET /
: Returns a simple greeting message.
curl -i [your_endpoint]
GET /user/:id
: Accepts a path parameter and returns a message including the user ID.
curl -i [your_endpoint]/user/123
GET /search
: Accepts a query parameter and returns a message with the search query.
curl -i "[your_endpoint]/search?q=example"
POST /register
: Accepts JSON data and returns a personalized message.
curl -i -X POST -H "Content-Type: application/json" -d @mock/rb.json [your_endpoint]/register
Replace [your_endpoint]
with the actual endpoint URL provided by the cdk deploy
command.