RPCServer
This commit is contained in:
21
packages/server/src/rpc/RPCServer.ts
Normal file
21
packages/server/src/rpc/RPCServer.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { createExpressMiddleware } from "@trpc/server/adapters/express"
|
||||
import { Config, Effect, Layer } from "effect"
|
||||
import { ExpressApp, ExpressAppLive } from "../express/ExpressApp"
|
||||
import { createTRPCContext } from "../trpc/context"
|
||||
import { router } from "./routers"
|
||||
|
||||
|
||||
export const RPCServerLive = Layer.effectDiscard(Effect.gen(function*() {
|
||||
const app = yield* ExpressApp
|
||||
|
||||
app.use(
|
||||
yield* Config.string("RPC_ROOT").pipe(Config.withDefault("/rpc")),
|
||||
|
||||
createExpressMiddleware({
|
||||
router: yield* router,
|
||||
createContext: createTRPCContext,
|
||||
}),
|
||||
)
|
||||
})).pipe(
|
||||
Layer.provide(ExpressAppLive)
|
||||
)
|
||||
Reference in New Issue
Block a user