20 lines
594 B
TypeScript
20 lines
594 B
TypeScript
import { createExpressMiddleware } from "@trpc/server/adapters/express"
|
|
import { Config, Effect, Layer } from "effect"
|
|
import { ExpressApp } 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,
|
|
}),
|
|
)
|
|
}))
|