Fix
This commit is contained in:
23
packages/server/src/rpc/RPCPlaygroundRoute.ts
Normal file
23
packages/server/src/rpc/RPCPlaygroundRoute.ts
Normal 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))
|
||||
}))
|
||||
}
|
||||
Reference in New Issue
Block a user