(
api: HttpApi.HttpApi<ApiId, Groups, ApiError, ApiR>,
options: {
readonly group: GroupName
readonly endpoint: EndpointName
readonly httpClient: HttpClient.HttpClient.With<E, R>
readonly transformClient?: ((client: HttpClient.HttpClient) => HttpClient.HttpClient) | undefined
readonly transformResponse?:
| ((effect: Effect.Effect<unknown, unknown>) => Effect.Effect<unknown, unknown>)
| undefined
readonly baseUrl?: URL | string | undefined
}
)
| 345 | * @category constructors |
| 346 | */ |
| 347 | export const endpoint = < |
| 348 | ApiId extends string, |
| 349 | Groups extends HttpApiGroup.Any, |
| 350 | ApiError, |
| 351 | ApiR, |
| 352 | const GroupName extends HttpApiGroup.Name<Groups>, |
| 353 | const EndpointName extends HttpApiEndpoint.Name<HttpApiGroup.EndpointsWithName<Groups, GroupName>>, |
| 354 | E, |
| 355 | R |
| 356 | >( |
| 357 | api: HttpApi.HttpApi<ApiId, Groups, ApiError, ApiR>, |
| 358 | options: { |
| 359 | readonly group: GroupName |
| 360 | readonly endpoint: EndpointName |
| 361 | readonly httpClient: HttpClient.HttpClient.With<E, R> |
| 362 | readonly transformClient?: ((client: HttpClient.HttpClient) => HttpClient.HttpClient) | undefined |
| 363 | readonly transformResponse?: |
| 364 | | ((effect: Effect.Effect<unknown, unknown>) => Effect.Effect<unknown, unknown>) |
| 365 | | undefined |
| 366 | readonly baseUrl?: URL | string | undefined |
| 367 | } |
| 368 | ): Effect.Effect< |
| 369 | Client.Method< |
| 370 | HttpApiEndpoint.WithName<HttpApiGroup.Endpoints<HttpApiGroup.WithName<Groups, GroupName>>, EndpointName>, |
| 371 | HttpApiGroup.Error<HttpApiGroup.WithName<Groups, GroupName>>, |
| 372 | ApiError | E, |
| 373 | R |
| 374 | >, |
| 375 | never, |
| 376 | HttpApiMiddleware.HttpApiMiddleware.Without< |
| 377 | | ApiR |
| 378 | | HttpApiGroup.Context<HttpApiGroup.WithName<Groups, GroupName>> |
| 379 | | HttpApiEndpoint.ContextWithName<HttpApiGroup.EndpointsWithName<Groups, GroupName>, EndpointName> |
| 380 | | HttpApiEndpoint.ErrorContextWithName<HttpApiGroup.EndpointsWithName<Groups, GroupName>, EndpointName> |
| 381 | > |
| 382 | > => { |
| 383 | let client: any = undefined |
| 384 | return makeClient(api, { |
| 385 | ...options, |
| 386 | predicate: ({ endpoint, group }) => group.identifier === options.group && endpoint.name === options.endpoint, |
| 387 | onEndpoint({ endpointFn }) { |
| 388 | client = endpointFn |
| 389 | } |
| 390 | }).pipe(Effect.map(() => client)) as any |
| 391 | } |
| 392 | |
| 393 | // ---------------------------------------------------------------------------- |
| 394 |
nothing calls this directly
no test coverage detected