Skip to content

Commit

Permalink
docs(readme): add a connInfo description
Browse files Browse the repository at this point in the history
  • Loading branch information
yusukebe committed Jul 3, 2024
1 parent b8fb04b commit 4130b9d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ my-hono-project/
index.html
```

Typically, you would run your app from the project's root directory (`my-hono-project`),
Typically, you would run your app from the project's root directory (`my-hono-project`),
so you would need the following code to serve the `static` folder:

```ts
Expand Down Expand Up @@ -210,6 +210,19 @@ app.use(
)
```

## ConnInfo Helper

You can use the [ConnInfo Helper](https://hono.dev/docs/helpers/conninfo) by importing `getConnInfo` from `@hono/node-server/conninfo`.

```ts
import { getConnInfo } from '@hono/node-server/conninfo'

app.get('/', (c) => {
const info = getConnInfo(c) // info is `ConnInfo`
return c.text(`Your remote address is ${info.remote.address}`)
})
```

## Accessing Node.js API

You can access the Node.js API from `c.env` in Node.js. For example, if you want to specify a type, you can write the following.
Expand Down

0 comments on commit 4130b9d

Please sign in to comment.