Skip to content

Commit

Permalink
Allow passing useServer
Browse files Browse the repository at this point in the history
Signed-off-by: Marcos Candeia <[email protected]>
  • Loading branch information
mcandeia committed Mar 8, 2025
1 parent e5687c8 commit 8baaf45
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions runtime/handler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export interface Bindings<TAppManifest extends AppManifest = AppManifest> {
renderer?: RendererOpts;
framework: Framework;
server?: Hono<DecoRouteState<TAppManifest>>;
useServer?: (
deco: Deco<TAppManifest>,
server: Hono<DecoRouteState<TAppManifest>>,
) => void;
}

const routes: Array<
Expand Down Expand Up @@ -127,6 +131,7 @@ export const handlerFor = <TAppManifest extends AppManifest = AppManifest>(
) => Promise<Response> | Response => {
const bindings = deco.bindings;
const hono = bindings?.server ?? new Hono<DecoRouteState<TAppManifest>>();
bindings?.useServer?.(deco, hono);
hono.use(async (ctx, next) => {
const renderFn = ctx.env?.RENDER_FN ?? bindings?.renderer?.renderFn;
const framework = bindings?.framework;
Expand Down

0 comments on commit 8baaf45

Please sign in to comment.