Overview
The Hono app provides a RESTful API with OpenAPI documentation. All routes are defined using the@hono/zod-openapi library for type-safe API definitions.
Route Configuration
Routes are configured insrc/routes/index.ts and mounted to the main application.
Base Configuration
File:src/routes/index.ts:9-53
OpenAPI Documentation
The API provides interactive documentation using Scalar API Reference:- Endpoint:
GET /openapi/docs - OpenAPI Spec:
GET /openapi - Theme: ElysiaJS
- Sources:
- Main API documentation
- Better Auth API documentation at
/api/auth/open-api/generate-schema
Authentication Routes
File:src/routes/auth.ts:5-12
Better Auth Handler
All authentication endpoints are handled by the Better Auth library./api/auth/**
Supported Methods: GET, POST
Handler: Delegates to Better Auth library for:
- User registration
- User login/logout
- Session management
- Email verification
- Password reset
- OAuth provider integration
LLMs Documentation Routes
File:src/routes/llms-docs.ts
Routes for serving documentation content to Large Language Models.
GET /llms-docs
Summary: Get combined documentation content Description: Retrieves all content from the docs folder and combines it into a single response. File:src/routes/llms-docs.ts:40-87
Request:
- Method:
GET - Path:
/llms-docs - No parameters required
200 OK
- Recursively reads all files from the
./docsdirectory - Concatenates file contents with double newline separators
- Estimates token count using 4 characters per token ratio
GET /llms-auth.txt
Summary: Better Auth OpenAPI documentation in Markdown Description: Provides the Better Auth API documentation in Markdown format, optimized for LLM consumption. File:src/routes/llms-docs.ts:103-126
Request:
- Method:
GET - Path:
/llms-auth.txt - No parameters required
200 OK
- Generates OpenAPI schema from Better Auth instance
- Converts to Markdown using
@scalar/openapi-to-markdown - Returns as plain text
GET /llms.txt
Summary: Main OpenAPI documentation in Markdown Description: Provides the complete API documentation in Markdown format following the llms.txt standard. File:src/routes/llms-docs.ts:140-162
Request:
- Method:
GET - Path:
/llms.txt - No parameters required
200 OK
- Generates OpenAPI 3.1 document from all registered routes
- Converts to Markdown format
- Must be registered after all other routes to index them properly
Route Registration Order
File:src/routes/index.ts:48-52
Routes are registered in the following order:
- OpenAPI documentation endpoints
- Authentication routes (
/api/auth/**) - LLMs documentation routes (
/llms-docs,/llms-auth.txt,/llms.txt)
/llms.txt and /llms-auth.txt routes must be registered last to properly index all other routes in the generated documentation.
Helper Functions
getAllFiles
File:src/routes/llms-docs.ts:17-33
Recursively retrieves all file paths from a directory.
dir- The directory path to traverse
- Array of absolute file paths
- Recursively explores subdirectories
- Returns only file paths (excludes directories)
- Preserves full path structure
Constants
File:src/routes/llms-docs.ts:10
