Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Built and signed on GitHub Actions
latest
ngasull/classicThis package works with DenoIt is unknown whether this package works with Cloudflare Workers, Node.js, Bun
JSR Score
41%
Published
2 months ago (0.1.1)
import type { ServedJSContext } from "jsr:@classic/js@0"; import type { Context } from "jsr:@hono/hono@^4.4.8"; import type { Env, Input, MiddlewareHandler } from "jsr:@hono/hono@^4.4.8/types"; import { createContext } from "./render.ts"; import type { Segment } from "./router.ts"; import type { JSXContextAPI, JSXContextInit } from "./types.ts"; const honoContext = createContext<Context>("hono"); export const $hono = (use: JSXContextAPI): Context => use(honoContext); export const classicRouter = <E extends Env, P extends string, I extends Input>( router: Segment<never, never, undefined>, { context = () => [], ...opts }: { js: ServedJSContext; context?: (c: Context<E, P, I>) => JSXContextInit<unknown>[]; }, ): MiddlewareHandler<E, P, I> => async (c, next) => await router.fetch(c.req.raw, { context: [honoContext.init(c), ...context(c)], ...opts, }) ?? next();