This commit is contained in:
Julien Valverdé
2024-07-09 01:03:45 +02:00
parent 48da2c6489
commit 3ac12bfe3e
3 changed files with 11 additions and 11 deletions

View File

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