This Hono application is a serverless REST API designed for Cloudflare Workers, utilizing Deno's Hono framework. It efficiently manages to-do items, leveraging Cloudflare's KV database for storage and the Wrangler CLI for seamless deployment. This setup offers a scalable, low-latency solution for task management in a distributed environment.
This is a RESTful API built using the Hono framework, which leverages Cloudflare environment variables, JWT authentication, and the Cloudflare KV database.
Before using this API, make sure you have the following prerequisites in place:
npm start
This will launch the API, and it will be accessible at the specified route.
The API uses various middleware functions for handling requests and authentication. These include:
helloMiddleware
: Logs a greeting message.superSecretWeapon
: Sets a secret value in the request context.authenticateUser
: Authenticates users based on a Bearer token.authMiddleware
: JWT token verification middleware.You can customize these middleware functions according to your requirements.
/docs
./
: Root endpoint with sample middleware and authentication./error
: Throws a sample error./ghl
: Logs the request body./todos
: Retrieves todos for a specific user./api/todos
: Retrieves all todos./api/todos
: Adds a new todo item for a specific user.The API includes error handling for various scenarios. Custom errors are defined in the error.ts
file. The API returns appropriate HTTP status codes and error messages.
Contributions to this project are welcome. Please follow the standard GitHub Fork and Pull Request workflow.
This project is licensed under the MIT License.