A full template for a serverless application built using Bun.
Features:
- AWS CDK for infrastructure-as-code to define Cloud resources. (
packages/cdk) - Custom Lambda Layer for Bun that plays nicely with Hono. (
packages/bun-layer) - Lambda based API using Hono. (
services/api) - Static-hosted web application using React. (
services/client) - Everything is neatly configured behind a CloudFront distribution (
packages/cdk)
How to use:
bun run developwill start the development server.bun run buildwill bundle all code and CDK definitions.bun run packagewill zip up all code to deploy.bun cdk [...]alias for aws-cdk CLI in the correct working directory.bun cdk synthwill synthesize a CloudFormation template.bun cdk diffwill show a diff between deployed CloudFormation state and local changes.bun cdk deploywill deploy the application to AWS.
The development server will hot-reload client changes. When using bun run develop the API server will also restart when changes are made.
Additionally, there's a proxy available in the development server that mimicks the CloudFront configuration. Any requests made to /api or /api/* will be forwarded to the API server locally. This way, you can hard code in your API request URLs in the client without worrying about local/deployed servers.