Skip to content

Commit 43fafb0

Browse files
authored
Add Cloudflare like test (#82)
1 parent db79ddd commit 43fafb0

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/fetch/index.t-test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,28 @@ import JSONT from "../json";
185185
}
186186
})();
187187
}
188+
189+
{
190+
type Spec = DefineApiEndpoints<{
191+
"/vectorize/indexes/:indexName": {
192+
get: {
193+
resBody: {
194+
200: { prop: string };
195+
};
196+
};
197+
};
198+
}>;
199+
(async () => {
200+
const CLOUDFLARE_API_HOST = "https://api.cloudflare.com/client/v4";
201+
const getCloudflareAccountEndpoint = (accountId: string) =>
202+
`${CLOUDFLARE_API_HOST}/accounts/${accountId}` as const;
203+
const basePath = getCloudflareAccountEndpoint("accountId");
204+
const f = fetch as FetchT<typeof basePath, Spec>;
205+
{
206+
const res = await f(`${basePath}/vectorize/indexes/indexA`, {});
207+
if (res.ok) {
208+
(await res.json()).prop;
209+
}
210+
}
211+
})();
212+
}

0 commit comments

Comments
 (0)