0.1.17 #18

Merged
Thilawyn merged 37 commits from next into master 2024-09-07 20:56:30 +02:00
Showing only changes of commit 253c3ec00d - Show all commits

View File

@@ -5,21 +5,21 @@ import { createTRCPErrorMapper } from "./createTRCPErrorMapper"
import { TRPCContextTransactionEnum, type TRPCContext, type TRPCContextTransaction } from "./TRPCContext"
export const Identifier = "@thilalib/TRPC/TRPCContextCreator"
export interface TRPCContextCreator<R> extends Context.Tag<typeof Identifier, TRPCContextCreatorService<R>> {}
export interface TRPCContextCreatorService<R> {
readonly createContext: (transaction: TRPCContextTransaction) => TRPCContext<R>
readonly createExpressContext: (context: CreateExpressContextOptions) => TRPCContext<R>
readonly createWebSocketContext: (context: CreateWSSContextFnOptions) => TRPCContext<R>
}
export class TRPCUnknownContextCreator extends Context.Tag("@thilalib/TRPC/TRPCContextCreator")<TRPCUnknownContextCreator,
TRPCContextCreatorService<unknown>
>() {}
export const TRPCUnknownContextCreator = Context.GenericTag<typeof Identifier, TRPCContextCreatorService<unknown>>(Identifier)
export const make = <R>() => {
class TRPCContextCreator extends Context.Tag("@thilalib/TRPC/TRPCContextCreator")<TRPCContextCreator,
TRPCContextCreatorService<R>
>() {}
const TRPCContextCreator = Context.GenericTag<typeof Identifier, TRPCContextCreatorService<R>>(Identifier)
const TRPCContextCreatorLive = Layer.effect(TRPCContextCreator, Effect.gen(function*() {
const runtime = yield* Effect.runtime<R>()
@@ -53,5 +53,5 @@ export const make = <R>() => {
return { createContext, createExpressContext, createWebSocketContext }
}))
return { TRPCContextCreator, TRPCContextCreatorLive }
return { TRPCContextCreator, TRPCContextCreatorLive } as const
}