Handlers
This commit is contained in:
@@ -24,7 +24,7 @@ export module TRPCContextCreator {
|
|||||||
effect: Effect.Effect<A, E, Services>,
|
effect: Effect.Effect<A, E, Services>,
|
||||||
options?: { readonly signal?: AbortSignal },
|
options?: { readonly signal?: AbortSignal },
|
||||||
) => Runtime.runPromise(runtime)(
|
) => Runtime.runPromise(runtime)(
|
||||||
effect.pipe(mapErrorsToTRPC),
|
effect.pipe(mapErrors),
|
||||||
options,
|
options,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ export module TRPCContextCreator {
|
|||||||
effect: Effect.Effect<A, E, Services>,
|
effect: Effect.Effect<A, E, Services>,
|
||||||
options?: Runtime.RunForkOptions,
|
options?: Runtime.RunForkOptions,
|
||||||
) => Runtime.runFork(runtime)(
|
) => Runtime.runFork(runtime)(
|
||||||
effect.pipe(mapErrorsToTRPC),
|
effect.pipe(mapErrors),
|
||||||
options,
|
options,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ export module TRPCContextCreator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const mapErrorsToTRPC = <A, E, R>(effect: Effect.Effect<A, E, R>) =>
|
const mapErrors = <A, E, R>(effect: Effect.Effect<A, E, R>) =>
|
||||||
Effect.sandbox(effect).pipe(
|
Effect.sandbox(effect).pipe(
|
||||||
Effect.catchTags({
|
Effect.catchTags({
|
||||||
Die: cause => Effect.fail(
|
Die: cause => Effect.fail(
|
||||||
|
|||||||
11
packages/server/src/trpc/handlers.ts
Normal file
11
packages/server/src/trpc/handlers.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import type { AnyRouter } from "@trpc/server"
|
||||||
|
import { createExpressMiddleware } from "@trpc/server/adapters/express"
|
||||||
|
import type { NodeHTTPHandlerOptions } from "@trpc/server/adapters/node-http"
|
||||||
|
import express from "express"
|
||||||
|
|
||||||
|
|
||||||
|
export const createExpressHandler = <TRouter extends AnyRouter>(
|
||||||
|
opts: NodeHTTPHandlerOptions<TRouter, express.Request, express.Response>,
|
||||||
|
) => {
|
||||||
|
const t = createExpressMiddleware(opts)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user