MCPcopy Create free account
hub / github.com/Effect-TS/effect / makeWith

Function makeWith

packages/effect/src/unstable/httpapi/HttpApiClient.ts:508–537  ·  view source on GitHub ↗
(
  api: HttpApi.HttpApi<ApiId, Groups>,
  options: {
    readonly httpClient: HttpClient.HttpClient.With<E, R>
    readonly transformResponse?:
      | ((effect: Effect.Effect<unknown, unknown, unknown>) => Effect.Effect<unknown, unknown, unknown>)
      | undefined
    readonly baseUrl?: URL | string | undefined
  }
)

Source from the content-addressed store, hash-verified

506 * @since 4.0.0
507 */
508export const makeWith = <ApiId extends string, Groups extends HttpApiGroup.Constraint, E, R>(
509 api: HttpApi.HttpApi<ApiId, Groups>,
510 options: {
511 readonly httpClient: HttpClient.HttpClient.With<E, R>
512 readonly transformResponse?:
513 | ((effect: Effect.Effect<unknown, unknown, unknown>) => Effect.Effect<unknown, unknown, unknown>)
514 | undefined
515 readonly baseUrl?: URL | string | undefined
516 }
517): Effect.Effect<
518 Client<Groups, Exclude<E, HttpClientError.HttpClientError>, R>,
519 never,
520 HttpApiGroup.MiddlewareClient<Groups>
521> => {
522 const client: Record<string, Record<string, any>> = {}
523 return makeClient(api, {
524 ...options,
525 onGroup({ group }) {
526 if (group.topLevel) return
527 InternalRecord.assignProperty(client, group.identifier, {})
528 },
529 onEndpoint({ endpoint, endpointFn, group }) {
530 InternalRecord.assignProperty(
531 group.topLevel ? client : client[group.identifier],
532 endpoint.identifier,
533 endpointFn
534 )
535 }
536 }).pipe(Effect.as(client)) as any
537}
538
539/**
540 * Builds a typed client object for a single API group from the supplied

Callers 1

makeFunction · 0.70

Calls 2

makeClientFunction · 0.70
pipeMethod · 0.65

Tested by

no test coverage detected