Config refactoring

This commit is contained in:
Julien Valverdé
2024-07-15 05:01:24 +02:00
parent 000c5bda35
commit f4eeb66459
6 changed files with 50 additions and 27 deletions

View File

@@ -1,6 +1,6 @@
import { Effect, Layer } from "effect"
import { expressHandler } from "trpc-playground/handlers/express"
import { rpcHTTPPlaygroundRoot, rpcHTTPRoot } from "../config"
import { ServerConfig } from "../ServerConfig"
import { ExpressApp } from "../http/ExpressApp"
import { RPCRouter } from "./RPCRouter"
@@ -10,10 +10,10 @@ export module RPCPlaygroundRoute {
export const Dev = Layer.effectDiscard(Effect.gen(function*() {
const app = yield* ExpressApp
const playgroundEndpoint = yield* rpcHTTPPlaygroundRoot
const playgroundEndpoint = yield* ServerConfig.rpcHTTPPlaygroundRoot
const handler = expressHandler({
trpcApiEndpoint: yield* rpcHTTPRoot,
trpcApiEndpoint: yield* ServerConfig.rpcHTTPRoot,
playgroundEndpoint,
router: yield* RPCRouter,
})

View File

@@ -1,6 +1,6 @@
import { createExpressMiddleware } from "@trpc/server/adapters/express"
import { Effect, Layer } from "effect"
import { rpcHTTPRoot } from "../config"
import { ServerConfig } from "../ServerConfig"
import { ExpressApp } from "../http/ExpressApp"
import { TRPCContextCreator } from "../trpc/TRPCContextCreator"
import { RPCRouter } from "./RPCRouter"
@@ -10,7 +10,7 @@ export module RPCRoute {
export const Live = Layer.effectDiscard(Effect.gen(function*() {
const app = yield* ExpressApp
app.use(yield* rpcHTTPRoot,
app.use(yield* ServerConfig.rpcHTTPRoot,
createExpressMiddleware({
router: yield* RPCRouter,
createContext: (yield* TRPCContextCreator).createExpressContext,