Skip to content

Commit

Permalink
Add typing support for hono variables in the handler (#34)
Browse files Browse the repository at this point in the history
* feat: add support for hono variables

* fix: use Variables instead of object

---------

Co-authored-by: CahidArda <[email protected]>
  • Loading branch information
ytkimirti and CahidArda authored Dec 5, 2024
1 parent 565e05c commit 4b4b9bd
Showing 1 changed file with 4 additions and 3 deletions.
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

0 comments on commit 4b4b9bd

Please sign in to comment.