RPCPlayground

This commit is contained in:
Julien Valverdé
2024-07-05 17:25:10 +02:00
parent a27a185759
commit 0f1d9c5ba6
4 changed files with 29 additions and 1 deletions

View File

@@ -0,0 +1,25 @@
import { Config, Effect, Layer } from "effect"
import { expressHandler } from "trpc-playground/handlers/express"
import { ExpressApp } from "../express/ExpressApp"
import { appRouter } from "./routers"
export module RPCPlayground {
export const Live = Layer.empty
export const Dev = Layer.effectDiscard(Effect.gen(function*() {
const app = yield* ExpressApp
const router = yield* appRouter
const playgroundEndpoint = yield* Config.string("RPC_PANEL_ROOT").pipe(Config.withDefault("/rpc/playground"))
const trpcApiEndpoint = yield* Config.string("RPC_ROOT").pipe(Config.withDefault("/rpc"))
app.use(playgroundEndpoint,
yield* Effect.promise(() => expressHandler({
trpcApiEndpoint,
playgroundEndpoint,
router,
}))
)
}))
}