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