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

Function endpointBuilder

packages/effect/src/unstable/httpapi/HttpApiClient.ts:679–693  ·  view source on GitHub ↗
(request?: {
        readonly params?: unknown
        readonly query?: unknown
      })

Source from the content-addressed store, hash-verified

677 : Schema.encodeSync(endpoint.query as unknown as Schema.ConstraintEncoder<unknown>)
678
679 const endpointBuilder = (request?: {
680 readonly params?: unknown
681 readonly query?: unknown
682 }) => {
683 const params = request?.params
684 const path = params === undefined
685 ? endpoint.path
686 : makeUrl((encodeParams === undefined ? params : encodeParams(params)) as Record<string, string | undefined>)
687 const queryInput = request?.query === undefined
688 ? undefined
689 : (encodeQuery === undefined ? request.query : encodeQuery(request.query)) as UrlParams.Input
690 const query = queryInput === undefined ? "" : UrlParams.toString(UrlParams.fromInput(queryInput))
691 const url = query === "" ? path : `${path}?${query}`
692 return options?.baseUrl === undefined ? url : new URL(url, options.baseUrl.toString()).toString()
693 }
694 InternalRecord.assignProperty(
695 group.topLevel ? builder : builder[group.identifier],
696 endpoint.identifier,

Callers

nothing calls this directly

Calls 1

toStringMethod · 0.65

Tested by

no test coverage detected