0.1.17 (#18)
Co-authored-by: Julien Valverdé <julien.valverde@mailo.com> Reviewed-on: #18
This commit was merged in pull request #18.
This commit is contained in:
38
src/TRPC/TRPCContext.ts
Normal file
38
src/TRPC/TRPCContext.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import type { TRPCError } from "@trpc/server"
|
||||
import { Data, type Effect, type Runtime } from "effect"
|
||||
import type { RuntimeFiber } from "effect/Fiber"
|
||||
import type express from "express"
|
||||
import type { IncomingMessage } from "node:http"
|
||||
import type { WebSocket } from "ws"
|
||||
|
||||
|
||||
export interface TRPCContext<R> {
|
||||
readonly runtime: Runtime.Runtime<R>
|
||||
|
||||
readonly run: <A, E>(
|
||||
effect: Effect.Effect<A, E, R>,
|
||||
options?: { readonly signal?: AbortSignal },
|
||||
) => Promise<A>
|
||||
|
||||
readonly fork: <A, E>(
|
||||
effect: Effect.Effect<A, E, R>,
|
||||
options?: Runtime.RunForkOptions,
|
||||
) => RuntimeFiber<A, TRPCError>
|
||||
|
||||
readonly transaction: TRPCContextTransaction
|
||||
}
|
||||
|
||||
|
||||
export type TRPCContextTransaction = Data.TaggedEnum<{
|
||||
readonly Express: {
|
||||
readonly req: express.Request
|
||||
readonly res: express.Response
|
||||
}
|
||||
|
||||
readonly WebSocket: {
|
||||
readonly req: IncomingMessage
|
||||
readonly res: WebSocket
|
||||
}
|
||||
}>
|
||||
|
||||
export const TRPCContextTransactionEnum = Data.taggedEnum<TRPCContextTransaction>()
|
||||
Reference in New Issue
Block a user