import type { Context } from "hono" import { Effect } from "effect" import { AppRuntime } from "../../effect/app-runtime" type AppEnv = Parameters[0] extends Effect.Effect ? R : never export function runRequest(name: string, c: Context, effect: Effect.Effect) { const url = new URL(c.req.url) return AppRuntime.runPromise( effect.pipe( Effect.withSpan(name, { attributes: { "http.method": c.req.method, "http.path": url.pathname, }, }), ), ) } export async function jsonRequest( name: string, c: C, effect: (c: C) => Effect.gen.Return, ) { return c.json( await runRequest( name, c, Effect.gen(() => effect(c)), ), ) }