MCPcopy Create free account
hub / github.com/effect-app/libs / ApiClientFactory

Class ApiClientFactory

packages/effect-app/src/client/apiClientFactory.ts:448–469  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

446 * Used to create clients for resource modules.
447 */
448export class ApiClientFactory
449 extends Context.Opaque<ApiClientFactory, Effect.Success<typeof makeApiClientFactory>>()("ApiClientFactory")
450{
451 static readonly layer = (config: ApiConfig) =>
452 ApiClientFactory.toLayer(makeApiClientFactory).pipe(Layer.provide(RpcSerializationLayer(config)))
453 static readonly layerFromConfig = Layer.unwrap(
454 Effect.gen(function*() {
455 const config = yield* DefaultApiConfig
456 return ApiClientFactory.layer(config)
457 })
458 )
459
460 static readonly makeFor =
461 (requestLevelLayers: Layer.Layer<never>, options?: ClientForOptions) =>
462 <M extends RequestsAny>(
463 resource: M
464 ) =>
465 ApiClientFactory.use((apiClientFactory) => {
466 const f = apiClientFactory(requestLevelLayers, options)
467 return f(resource)
468 })
469}

Callers

nothing calls this directly

Calls 6

RpcSerializationLayerFunction · 0.85
pipeMethod · 0.65
toLayerMethod · 0.65
useMethod · 0.65
fFunction · 0.50
provideMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…