Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Introduce ConnInfo helper/adapter #2595

Merged
merged 11 commits into from May 22, 2024

Conversation

nakasyou
Copy link
Contributor

@nakasyou nakasyou commented May 3, 2024

I created ConnInfo helper/adapter for Bun, Deno and CF Workers.
You can get client IP Address with Hono easier if we marge PR.

This provides runtime-less ConnInfo object.

For example, you can get IP Address on Bun:

import { Hono } from 'hono'
import { getConnInfo } from 'hono/bun'

const app = new Hono()

app.get('/', c => c.text(`Your ip address is ${getConnInfo(c).remote.address}!!`))

Bun.serve(app)

If you want to use Workers, replace import:

import { getConnInfo } from 'hono/cloudflare-workers'

In Deno:

import { getConnInfo } from 'https://deno.land/x/hono/helper.ts'

Author should do the followings, if applicable

  • Add tests
  • Run tests
  • bun denoify to generate files for Deno

src/adapter/bun/conninfo.ts Outdated Show resolved Hide resolved
src/adapter/bun/conninfo.ts Outdated Show resolved Hide resolved
@yusukebe
Copy link
Member

yusukebe commented May 7, 2024

@nakasyou

CI fails. Could you run bun run lint:fix (As you said on X, I might have made a mistake in configuring Prettier and ESLint)?

@nakasyou
Copy link
Contributor Author

nakasyou commented May 7, 2024

@yusukebe

I ran bun run lint:fix.

If strings include single quote, CI fails due to Prettier or ESLint.

Prettier recommends "it's", but ESLint recommends 'it\'s'

src/adapter/bun/conninfo.test.ts Outdated Show resolved Hide resolved
src/adapter/bun/conninfo.test.ts Outdated Show resolved Hide resolved
@yusukebe yusukebe added the v4.4 label May 9, 2024
Copy link
Member

@yusukebe yusukebe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@yusukebe
Copy link
Member

yusukebe commented May 9, 2024

Hey @nakasyou

Looks great! It's finished. This is a new feature, so I'm planning to release it in the next minor release, v4.4. So, I leave this PR not merged yet. Thanks!

@nakasyou
Copy link
Contributor Author

nakasyou commented May 9, 2024

@yusukebe, I see. Thanks!

@yusukebe yusukebe added v4.4 and removed v4.3 labels May 10, 2024
@nakasyou nakasyou mentioned this pull request May 19, 2024
@yusukebe yusukebe changed the base branch from main to next May 22, 2024 20:36
@yusukebe yusukebe merged commit a8a5fb9 into honojs:next May 22, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants