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