MCPcopy Index your code
hub / github.com/Effect-TS/effect / makeWith

Function makeWith

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

Source from the content-addressed store, hash-verified

272 * @category constructors
273 */
274export const makeWith = <ApiId extends string, Groups extends HttpApiGroup.Any, ApiError, ApiR, E, R>(
275 api: HttpApi.HttpApi<ApiId, Groups, ApiError, ApiR>,
276 options: {
277 readonly httpClient: HttpClient.HttpClient.With<E, R>
278 readonly transformResponse?:
279 | ((effect: Effect.Effect<unknown, unknown>) => Effect.Effect<unknown, unknown>)
280 | undefined
281 readonly baseUrl?: URL | string | undefined
282 }
283): Effect.Effect<
284 Simplify<Client<Groups, ApiError | E, R>>,
285 never,
286 HttpApiMiddleware.HttpApiMiddleware.Without<ApiR | HttpApiGroup.ClientContext<Groups>>
287> => {
288 const client: Record<string, Record<string, any>> = {}
289 return makeClient(api, {
290 ...options,
291 onGroup({ group }) {
292 if (group.topLevel) return
293 client[group.identifier] = {}
294 },
295 onEndpoint({ endpoint, endpointFn, group }) {
296 ;(group.topLevel ? client : client[group.identifier])[endpoint.name] = endpointFn
297 }
298 }).pipe(Effect.map(() => client)) as any
299}
300
301/**
302 * @since 1.0.0

Callers 1

makeFunction · 0.70

Calls 3

makeClientFunction · 0.70
pipeMethod · 0.65
mapMethod · 0.65

Tested by

no test coverage detected