(
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
}
)
| 272 | * @category constructors |
| 273 | */ |
| 274 | export 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 |
no test coverage detected
searching dependent graphs…