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

docs: add more details to cloudflare workers bindings section #548

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jw-12138
Copy link

No description provided.

PASSWORD: string
}

export const handler = async (c: Context<{
Copy link
Member

Choose a reason for hiding this comment

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

We don't recommend using Context for c for the following reasons:

https://hono.dev/docs/guides/best-practices#don-t-make-controllers-when-possible

```ts
// Generated by Wrangler by running `wrangler types`

interface Env {
Copy link
Member

Choose a reason for hiding this comment

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

The naming Env will be confusing because we often use the following code:

type Env = {
  Bindings: {
    KV: KVNamespace
  },
  Variables: {
    foo: string
  }
}

Actually, the code which is generated from C3 does not use Env but uses CloudflareBindings:

// Generated by Wrangler by running `wrangler types --env-interface CloudflareBindings`

interface CloudflareBindings {
	MY_VARIABLE: "production_value";
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants