* * @param {string} title * @param {{ accountId: string; accountEmail: string | undefined; apiKey: string; }} args
(title, args)
| 329 | * @param {{ accountId: string; accountEmail: string | undefined; apiKey: string; }} args |
| 330 | */ |
| 331 | async function createNamespace(title, args) { |
| 332 | const response = await fetch( |
| 333 | `${apiBase}/accounts/${args.accountId}/storage/kv/namespaces`, |
| 334 | { |
| 335 | method: 'POST', |
| 336 | headers: Object.assign( |
| 337 | { 'content-type': 'application/json' }, |
| 338 | buildAuthHeaders(args.apiKey, args.accountEmail) |
| 339 | ), |
| 340 | body: JSON.stringify({ title }) |
| 341 | } |
| 342 | ); |
| 343 | if (!response.ok) { |
| 344 | throw new Error( |
| 345 | `Error creating namespace - ${response.status}: ${ |
| 346 | response.statusText |
| 347 | }\n${await response.text()}` |
| 348 | ); |
| 349 | } |
| 350 | const data2 = await response.json(); |
| 351 | return data2.result; |
| 352 | } |
| 353 | |
| 354 | /** |
| 355 | * @param {{ site: StaticSite | null; name: string; accountId: string; accountEmail: string | undefined; apiKey: string; }} args |
no test coverage detected