This repository contains an example API built with Hono. It leverages Drizzle ORM for database operations on Neon and uses InversifyJS for dependency injection. The entire application is deployed on Cloudflare Workers for a serverless and globally distributed environment.
The API is deployed and live at the following URL:
- Live API URL: https://hono-api-example.adrianmjim.workers.dev
- Hono Framework: A fast, minimalist web framework designed for Cloudflare Workers.
- Drizzle ORM: A lightweight and type-safe SQL query builder and ORM.
- Neon Database: A serverless PostgreSQL solution.
- InversifyJS: A robust dependency injection library to promote modular and maintainable code.
- Serverless Deployment: Easily deploy your API on Cloudflare Workers for scalability and global performance.
Follow these instructions to set up the project locally and get started with development.
-
Clone the repository:
git clone https://github.com/adrianmjim/hono-api-example.git cd hono-api-example
-
Install dependencies using pnpm:
pnpm install
-
Configure Environment Variables:
Create a .env file in the root directory with your environment-specific variables. For example:
DATABASE_URL=postgres://user:password@your-neon-database-url:port/database
Adjust these variables according to your configuration.
To run the API locally, use:
pnpm dev
To deploy the API to Cloudflare Workers:
pnpm run deploy
Make sure your wrangler.json is properly configured with your account details and project settings. This command builds and deploys your API to Cloudflare Workers.
Here are some example endpoints included in this API:
-
GET /
Returns a ok message. -
GET /cats
Retrieves a list of cats. -
POST /cats
Creates a new cat. -
GET /cats/:id
Retrieves a specific cat by its ID. -
PUT /cats/:id
Updates an existing cat. -
DELETE /cats/:id
Deletes an cat.
Note: These endpoints are provided as examples. Adjust or expand them to fit your application’s requirements.
Contributions, issues and feature requests are welcome.
👤 Adrián Martínez Jiménez
- Github: @adrianmjim
See also the list of contributors who participated in this project.
Please ⭐️ this repository if this project helped you!
Copyright © 2025 Adrián Martínez Jiménez.
This project is licensed under the MIT License - see the LICENSE file for details.