https://github.com/thesmartmonkey/create-hono-cloudflare-workers-rest-api
Lightweight Honojs rest api template for side project or micro Saas on cloudflare workers
https://github.com/thesmartmonkey/create-hono-cloudflare-workers-rest-api
bun cloudflare-workers hono rest-api typescript
Last synced: about 1 year ago
JSON representation
Lightweight Honojs rest api template for side project or micro Saas on cloudflare workers
- Host: GitHub
- URL: https://github.com/thesmartmonkey/create-hono-cloudflare-workers-rest-api
- Owner: TheSmartMonkey
- License: mit
- Created: 2024-04-13T15:23:46.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-29T20:18:37.000Z (about 1 year ago)
- Last Synced: 2025-04-29T21:23:45.581Z (about 1 year ago)
- Topics: bun, cloudflare-workers, hono, rest-api, typescript
- Language: TypeScript
- Homepage:
- Size: 279 KB
- Stars: 12
- Watchers: 1
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# create-hono-cloudflare-workers-rest-api
๐ Welcome to [HonoJS](https://hono.dev/) REST API Template ๐
## Features
๐ ๏ธ Minimal Setup, Maximum Power
โ๏ธ Middleware Magic
๐ JWT token Authentication
๐ Swagger UI and openapi documentation (with auto generate code for the frontend)
โ
Route validation with [zod](https://zod.dev/)
๐งช Testing with [jest](https://jestjs.io/fr/)
๐ฆ Beautiful code with [eslint](https://eslint.org/) and [prettier](https://prettier.io/)
## Getting Started
Create a new project
```sh
npx degit https://github.com/TheSmartMonkey/create-hono-cloudflare-workers-rest-api backend
```
Create a `wrangler.toml` based on `wrangler.default.toml`
Install dependancies
```sh
bun i
```
Start coding ๐งโ๐ป
```sh
bun start
```
Deploy to cloudflare ๐
```sh
bun run deploy
```
Swagger UI ๐ : http://127.0.0.1:8787/public/api
You can add the JWT token in the Authorize button in the top right corner
Exemple token with secret `1234` :
```sh
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJmYWtlVXNlcklkIiwiZW1haWwiOiJmYWtlRW1haWwiLCJpYXQiOjE3NDAyMjUwODh9.PcHnkcIxknYZbaR7G4R0KaYAWAKeaHJ5cZYIUIPSYRA
```
Encode a JWT token: [JWT Encoder/Decoder](https://10015.io/tools/jwt-encoder-decoder)
## Generate openapi spec
Edit `openapitools.json` config to specify the code generation (typescript-angular, typescript-node, etc)
Then run this command to generate the code
```sh
bun run genapi
```
You should have the generated code in `dist/api`
## Testing
Test you code ๐งช
```sh
bun run test
```
### Run Specific Tests
Run unit tests ๐งช
_Test individual components or functions_
```sh
bun run unit
```
Run integration tests ๐งช
_Test your code with external dependencies like databases, APIs, etc_
```sh
bun run integration
```
### Grouping Tests
Tests are grouped using Jest's `@group` annotation:
```js
/**
* @group unit
*/
```
```js
/**
* @group integration
*/
```
This helps in organizing and running specific groups of tests
## More Commands
Fix you code to make it Beautiful ๐ฆ
```sh
bun run fix
```
For more commands:
```sh
bun run
```
Happy coding! ๐