0.1.17 (#18)
All checks were successful
Publish / publish (push) Successful in 13s
Lint / lint (push) Successful in 11s

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:
Julien Valverdé
2024-09-07 20:56:30 +02:00
parent 07578a7ac7
commit 02d8e38f4d
25 changed files with 666 additions and 82 deletions

38
src/TRPC/TRPCContext.ts Normal file
View 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>()