TRPC context creator

This commit is contained in:
Julien Valverdé
2024-07-09 02:36:37 +02:00
parent c25c525d6f
commit 139d52a9a1
2 changed files with 7 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
import { TRPCError } from "@trpc/server"
import type { CreateExpressContextOptions } from "@trpc/server/adapters/express"
import type { CreateWSSContextFnOptions } from "@trpc/server/adapters/ws"
import { Context, Effect, Layer, Runtime } from "effect"
import type { Services } from "../Services"
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
*/
export class TRPCContextCreator extends Context.Tag("TRPCContextCreator")<TRPCContextCreator,
(opts: CreateExpressContextOptions) => TRPCContext
(opts:
| CreateExpressContextOptions
| CreateWSSContextFnOptions
) => TRPCContext
>() {}
export module TRPCContextCreator {
@@ -20,7 +24,7 @@ export module TRPCContextCreator {
return ({ req }) => ({
runtime,
run,
req,
// req,
})
}))
}