import { Effect, Layer } from "effect" import { expressHandler } from "trpc-playground/handlers/express" import { rpcHTTPPlaygroundRoot, rpcHTTPRoot } from "../config" import { ExpressApp } from "../express/ExpressApp" import { RPCRouter } from "./RPCRouter" export module RPCPlaygroundRoute { export const Live = Layer.empty export const Dev = Layer.effectDiscard(Effect.gen(function*() { const app = yield* ExpressApp const playgroundEndpoint = yield* rpcHTTPPlaygroundRoot const handler = expressHandler({ trpcApiEndpoint: yield* rpcHTTPRoot, playgroundEndpoint, router: yield* RPCRouter, }) app.use(playgroundEndpoint, yield* Effect.promise(() => handler)) })) }