MCPcopy Create free account
hub / github.com/cfworker/cfworker / getNamespaceKeys

Function getNamespaceKeys

packages/dev/src/cloudflare-api.js:307–324  ·  view source on GitHub ↗

* * @param {string} id * @param {{ accountId: string; accountEmail: string | undefined; apiKey: string; }} args * @returns {Promise<{ name: string; }[]>}

(id, args)

Source from the content-addressed store, hash-verified

305 * @returns {Promise<{ name: string; }[]>}
306 */
307async function getNamespaceKeys(id, args) {
308 const response = await fetch(
309 `${apiBase}/accounts/${args.accountId}/storage/kv/namespaces/${id}/keys?limit=1000`,
310 {
311 headers: buildAuthHeaders(args.apiKey, args.accountEmail)
312 }
313 );
314 if (!response.ok) {
315 throw new Error(
316 `Error fetching namespace keys - ${response.status}: ${
317 response.statusText
318 }\n${await response.text()}`
319 );
320 }
321 const data = await response.json();
322 // @ts-ignore
323 return data.result;
324}
325
326/**
327 *

Callers 1

bulkDeleteFunction · 0.85

Calls 3

buildAuthHeadersFunction · 0.85
textMethod · 0.45
jsonMethod · 0.45

Tested by

no test coverage detected