Template Hono API
- TypeScript 95.5%
- JavaScript 2.4%
- Makefile 2.1%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| src | ||
| .gitignore | ||
| .prettierrc.json | ||
| eslint.config.js | ||
| LICENSE | ||
| Makefile | ||
| package.json | ||
| pnpm-lock.yaml | ||
| pnpm-workspace.yaml | ||
| README.md | ||
| tsconfig.json | ||
| wrangler.jsonc | ||
Hono API
Small API built with Hono.
Run
Install dependencies and start Wrangler's local development server:
pnpm install
make dev
Build a production Worker bundle without deploying it:
make build
Wrangler listens on http://localhost:8787 by default.
Routes:
GET /ping— public health checkGET /secret— protected example; denied until authentication is replacedGET /docs/— Swagger UIGET /docs/doc.json— generated OpenAPI 3.1 document
Add endpoint
Create a module in src/endpoints with a createRoute definition and registration function:
export function registerExample(app: OpenAPIHono<AppEnv>): void {
app.openapi(route, (context) => context.json({ message: "example" }, 200));
}
Register it in src/server.ts. Add route-scoped middleware to the createRoute definition when
the endpoint needs authorization:
const route = createRoute({
method: "get",
path: "/example",
middleware: [auth(authorizer)],
// ...
});
OpenAPI is generated from route schemas at /docs/doc.json; no separate generation step is
needed.
Deploy
Authenticate Wrangler, then deploy the Worker:
make deploy