Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ For efficient documentation access from web URLs, convert paths using the follow

Simply remove the `https://hono.dev` portion and append the path to the `hono docs` command to access documentation directly in the terminal.

**Important**: When you need to fetch information from Hono documentation (e.g., `https://hono.dev/docs/middleware/builtin/basic-auth`), always use the `hono docs` command instead of WebFetch. For example:

- Instead of: `WebFetch(https://hono.dev/docs/middleware/builtin/basic-auth)`
- Use: `hono docs /docs/middleware/builtin/basic-auth`

### Recommended Workflow

1. **Search first**: Use `hono search <keyword>` to find relevant documentation
Expand Down
176 changes: 113 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,80 +14,25 @@ npm install -g @hono/cli
# Show help
hono --help

# Send request to Hono app
hono request

# Display documentation
hono docs

# Search documentation
hono search middleware
```

## Commands

- `request [file]` - Send request to Hono app using `app.request()`
- `docs [path]` - Display Hono documentation
- `search <query>` - Search Hono documentation

### `request`

Send HTTP requests to your Hono application using the built-in `app.request()` method. This is particularly useful for testing and development.

```bash
hono request [file] [options]
```

**Arguments:**

- `file` - Path to the Hono app file (TypeScript/JSX supported, optional)

**Options:**

- `-P, --path <path>` - Request path (default: "/")
- `-X, --method <method>` - HTTP method (default: GET)
- `-d, --data <data>` - Request body data
- `-H, --header <header>` - Custom headers (can be used multiple times)

**Examples:**

```bash
# GET request to default app root (uses src/index.ts or src/index.tsx)
# Send request to Hono app
hono request

# GET request to specific path
hono request -P /users/123

# POST request with data
hono request -P /api/users -X POST -d '{"name":"Alice"}'

# Request to specific file
hono request -P /api src/your-app.ts

# Request with custom headers
hono request -P /api/protected -H 'Authorization: Bearer token' -H 'User-Agent: MyApp' src/your-app.ts

# PUT request with data and headers to specific file
hono request -P /api/users/1 -X PUT -d '{"name":"Bob"}' -H 'Content-Type: application/json' src/your-app.ts

# Complex example with multiple options
hono request -P /webhook -X POST -d '{"event":"test"}' -H 'Content-Type: application/json' -H 'X-API-Key: secret' my-project/server.ts
# Start server
hono serve
```

**Response Format:**

The command returns a JSON object with the following structure:
## Commands

```json
{
"status": 200,
"body": "{\"message\":\"Hello World\"}",
"headers": {
"content-type": "application/json",
"x-custom-header": "value"
}
}
```
- `docs [path]` - Display Hono documentation
- `search [query]` - Search Hono documentation
- `request [file]` - Send request to Hono app using `app.request()`
- `serve [entry]` - Start server for Hono app

### `docs`

Expand Down Expand Up @@ -175,6 +120,111 @@ Example output:
Command: hono docs /docs/middleware/third-party
```

### `request`

Send HTTP requests to your Hono application using the built-in `app.request()` method. This is particularly useful for testing and development.

```bash
hono request [file] [options]
```

**Arguments:**

- `file` - Path to the Hono app file (TypeScript/JSX supported, optional)

**Options:**

- `-P, --path <path>` - Request path (default: "/")
- `-X, --method <method>` - HTTP method (default: GET)
- `-d, --data <data>` - Request body data
- `-H, --header <header>` - Custom headers (can be used multiple times)

**Examples:**

```bash
# GET request to default app root (uses src/index.ts or src/index.tsx)
hono request

# GET request to specific path
hono request -P /users/123

# POST request with data
hono request -P /api/users -X POST -d '{"name":"Alice"}'

# Request to specific file
hono request -P /api src/your-app.ts

# Request with custom headers
hono request -P /api/protected -H 'Authorization: Bearer token' -H 'User-Agent: MyApp' src/your-app.ts

# PUT request with data and headers to specific file
hono request -P /api/users/1 -X PUT -d '{"name":"Bob"}' -H 'Content-Type: application/json' src/your-app.ts

# Complex example with multiple options
hono request -P /webhook -X POST -d '{"event":"test"}' -H 'Content-Type: application/json' -H 'X-API-Key: secret' my-project/server.ts
```

**Response Format:**

The command returns a JSON object with the following structure:

```json
{
"status": 200,
"body": "{\"message\":\"Hello World\"}",
"headers": {
"content-type": "application/json",
"x-custom-header": "value"
}
}
```

### `serve`

Start a server for your Hono application. This is a simple server specialized for Hono applications with built-in TypeScript and JSX support.

```bash
hono serve [entry] [options]
```

**Arguments:**

- `entry` - Entry file for your Hono app (TypeScript/JSX supported, optional)

**Options:**

- `-p, --port <port>` - Port number (default: 7070)
- `--show-routes` - Show registered routes
- `--use <middleware>` - Use middleware (can be used multiple times)

**Examples:**

```bash
# Start server with default empty app (no entry file needed)
hono serve

# Start server on specific port
hono serve -p 8080 src/app.ts

# Start server with specific entry file
hono serve src/app.ts

# Start server and show routes
hono serve --show-routes src/app.ts

# Start server with middleware
hono serve --use 'cors()' src/app.ts

# Start server with multiple middleware
hono serve --use 'cors()' --use 'logger()' src/app.ts

# Start server with authentication and static file serving
hono serve --use 'basicAuth({username:"foo", password:"bar"})' --use "serveStatic({ root: './' })"

# Combine all options
hono serve -p 8080 --show-routes --use 'cors()' --use 'logger()' src/app.ts
```

## Authors

- Yusuke Wada https://github.com/yusukebe
Expand Down
Loading