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

Add typing support for hono variables in the handler #34

Merged
merged 2 commits into from
Dec 5, 2024

Conversation

ytkimirti
Copy link
Contributor

From discord support


https://upstash.com/docs/workflow/quickstarts/hono#step-3-create-a-workflow-endpoint in this example which showcases using hono context in the workflow serve. It only has support for Bindings. I am not able to configure or type Variables in the serve function so the handler(c) is throwing a lint error saying it cannot accept the payload.

the following is my Hono object creation code.

interface Bindings extends WorkflowBindings {
  db:MyDb
}
export const workflowsHandler = new Hono<{
  Variables: RootVariables;
  Bindings: Bindings;
}>();

TBindings extends WorkflowBindings = WorkflowBindings,
TVariables extends object = object,
Copy link
Contributor

Choose a reason for hiding this comment

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

on a type-level the exact same, but I suggest using the Variables type provided directly by Hono:

import { Variables } from "hono/types"

@CahidArda CahidArda merged commit 4b4b9bd into main Dec 5, 2024
17 checks passed
@CahidArda CahidArda deleted the feat-hono-vars branch December 5, 2024 12:39
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.

3 participants