21 lines
652 B
TypeScript
21 lines
652 B
TypeScript
import { createExpressMiddleware } from "@trpc/server/adapters/express"
|
|
import { Effect, Layer } from "effect"
|
|
import { ExpressApp } from "../express/ExpressApp"
|
|
import { TRPCContextCreator } from "../trpc/TRPCContextCreator"
|
|
import { RPCRouter } from "./RPCRouter"
|
|
import { rpcRoot } from "./config"
|
|
|
|
|
|
export module RPCServer {
|
|
export const Live = Layer.effectDiscard(Effect.gen(function*() {
|
|
const app = yield* ExpressApp
|
|
|
|
app.use(yield* rpcRoot,
|
|
createExpressMiddleware({
|
|
router: yield* RPCRouter,
|
|
createContext: yield* TRPCContextCreator,
|
|
}),
|
|
)
|
|
}))
|
|
}
|