TRPC context creator
This commit is contained in:
@@ -10,5 +10,5 @@ export interface TRPCContext {
|
|||||||
options?: { readonly signal?: AbortSignal }
|
options?: { readonly signal?: AbortSignal }
|
||||||
) => Promise<A>
|
) => Promise<A>
|
||||||
|
|
||||||
req: Request
|
// req: Request
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { TRPCError } from "@trpc/server"
|
import { TRPCError } from "@trpc/server"
|
||||||
import type { CreateExpressContextOptions } from "@trpc/server/adapters/express"
|
import type { CreateExpressContextOptions } from "@trpc/server/adapters/express"
|
||||||
|
import type { CreateWSSContextFnOptions } from "@trpc/server/adapters/ws"
|
||||||
import { Context, Effect, Layer, Runtime } from "effect"
|
import { Context, Effect, Layer, Runtime } from "effect"
|
||||||
import type { Services } from "../Services"
|
import type { Services } from "../Services"
|
||||||
import type { TRPCContext } from "./TRPCContext"
|
import type { TRPCContext } from "./TRPCContext"
|
||||||
@@ -9,7 +10,10 @@ import type { TRPCContext } from "./TRPCContext"
|
|||||||
* Provides a function that instantiates a fresh context for each tRPC procedure call
|
* Provides a function that instantiates a fresh context for each tRPC procedure call
|
||||||
*/
|
*/
|
||||||
export class TRPCContextCreator extends Context.Tag("TRPCContextCreator")<TRPCContextCreator,
|
export class TRPCContextCreator extends Context.Tag("TRPCContextCreator")<TRPCContextCreator,
|
||||||
(opts: CreateExpressContextOptions) => TRPCContext
|
(opts:
|
||||||
|
| CreateExpressContextOptions
|
||||||
|
| CreateWSSContextFnOptions
|
||||||
|
) => TRPCContext
|
||||||
>() {}
|
>() {}
|
||||||
|
|
||||||
export module TRPCContextCreator {
|
export module TRPCContextCreator {
|
||||||
@@ -20,7 +24,7 @@ export module TRPCContextCreator {
|
|||||||
return ({ req }) => ({
|
return ({ req }) => ({
|
||||||
runtime,
|
runtime,
|
||||||
run,
|
run,
|
||||||
req,
|
// req,
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user