From fd90ed60b093883bd714922eae9bf5e4a6f17cb8 Mon Sep 17 00:00:00 2001 From: daishi Date: Wed, 28 Aug 2024 23:19:02 +0900 Subject: [PATCH] experimental: expose hono context --- packages/waku/src/lib/hono/runner.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/waku/src/lib/hono/runner.ts b/packages/waku/src/lib/hono/runner.ts index 8031ca5d6..f0bbc4d72 100644 --- a/packages/waku/src/lib/hono/runner.ts +++ b/packages/waku/src/lib/hono/runner.ts @@ -3,6 +3,9 @@ import type { MiddlewareHandler } from 'hono'; import { resolveConfig } from '../config.js'; import type { HandlerContext, MiddlewareOptions } from '../middleware/types.js'; +// Experimental Unstable API +const HONO_CONTEXT = '__hono_context'; + const createEmptyReadableStream = () => new ReadableStream({ start(controller) { @@ -37,7 +40,9 @@ export const runner = (options: MiddlewareOptions): MiddlewareHandler => { headers: c.req.header(), }, res: {}, - context: {}, + context: { + [HONO_CONTEXT]: c, + }, }; const handlers = await handlersPromise; const run = async (index: number) => {