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: enable adding types for Env variables #191

Merged
merged 3 commits into from
May 1, 2022
Merged

Conversation

yusukebe
Copy link
Member

@yusukebe yusukebe commented May 1, 2022

Enable adding types for Env variables using generics in Module Worker mode.

interface Env {
  API_KEY: string
  API_SECRET: string
  MY_KV: KVNamespace
}

const app = new Hono<Env>()

app.get('/', (c) => {
  const key = c.env.API_KEY
  const secret = c.env.API_SECRET
  const message = getMessage({ key, secret })
  return c.text(`Hono! ${message}`)
})

export default app

スクリーンショット 2022-05-01 20 01 48

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.

None yet

1 participant