Template Hono API
  • TypeScript 95.5%
  • JavaScript 2.4%
  • Makefile 2.1%
Find a file Use this template
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-06-25 00:19:46 -06:00
src Init 2026-06-25 00:03:52 -06:00
.gitignore Init 2026-06-25 00:03:52 -06:00
.prettierrc.json Init 2026-06-25 00:03:52 -06:00
eslint.config.js Init 2026-06-25 00:03:52 -06:00
LICENSE LICENSE 2026-06-25 00:19:46 -06:00
Makefile Init 2026-06-25 00:03:52 -06:00
package.json Init 2026-06-25 00:03:52 -06:00
pnpm-lock.yaml LICENSE 2026-06-25 00:19:46 -06:00
pnpm-workspace.yaml LICENSE 2026-06-25 00:19:46 -06:00
README.md Init 2026-06-25 00:03:52 -06:00
tsconfig.json Init 2026-06-25 00:03:52 -06:00
wrangler.jsonc Init 2026-06-25 00:03:52 -06:00

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 check
  • GET /secret — protected example; denied until authentication is replaced
  • GET /docs/ — Swagger UI
  • GET /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