MCPcopy Index your code
hub / github.com/anomalyco/opencode / prepare

Function prepare

packages/client/src/generated/client.ts:143–161  ·  view source on GitHub ↗
(descriptor: RequestDescriptor, requestOptions?: RequestOptions)

Source from the content-addressed store, hash-verified

141 const fetch = options.fetch ?? globalThis.fetch
142
143 const prepare = (descriptor: RequestDescriptor, requestOptions?: RequestOptions) => {
144 const url = new URL(descriptor.path, options.baseUrl)
145 for (const [key, value] of Object.entries(descriptor.query ?? {})) appendQuery(url.searchParams, key, value)
146 const headers = new Headers(options.headers)
147 for (const [key, value] of Object.entries(descriptor.headers ?? {})) {
148 if (value !== undefined && value !== null) headers.set(key, String(value))
149 }
150 for (const [key, value] of new Headers(requestOptions?.headers)) headers.set(key, value)
151 if (descriptor.body !== undefined && !headers.has("content-type")) headers.set("content-type", "application/json")
152 return {
153 url,
154 init: {
155 method: descriptor.method,
156 signal: requestOptions?.signal,
157 headers,
158 body: descriptor.body === undefined ? undefined : JSON.stringify(descriptor.body),
159 } satisfies RequestInit,
160 }
161 }
162
163 const execute = async (descriptor: RequestDescriptor, requestOptions?: RequestOptions) => {
164 try {

Callers 1

executeFunction · 0.70

Calls 2

appendQueryFunction · 0.85
setMethod · 0.45

Tested by

no test coverage detected