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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions platforms/hono.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Context } from "hono";
import type { RouteFunction, WorkflowServeOptions } from "../src";
import { serve as serveBase } from "../src";
import { Variables } from "hono/types";

export type WorkflowBindings = {
QSTASH_TOKEN: string;
Expand All @@ -21,13 +22,13 @@ export type WorkflowBindings = {
*/
export const serve = <
TInitialPayload = unknown,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
TBindings extends WorkflowBindings = WorkflowBindings,
TVariables extends Variables = Variables,
>(
routeFunction: RouteFunction<TInitialPayload>,
options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">
): ((context: Context<{ Bindings: TBindings }>) => Promise<Response>) => {
const handler = async (context: Context<{ Bindings: TBindings }>) => {
): ((context: Context<{ Bindings: TBindings; Variables: TVariables }>) => Promise<Response>) => {
const handler = async (context: Context<{ Bindings: TBindings; Variables: TVariables }>) => {
const environment = context.env;
const request = context.req.raw;

Expand Down
Loading