This commit is contained in:
imeepos
2025-07-10 22:22:22 +08:00
parent bda9eb1a6b
commit 64f90bc259
5 changed files with 172 additions and 12 deletions

View File

@@ -59,7 +59,8 @@ export class CloudflareKVClient {
async put(key: string, value: any, metadata?: Record<string, any>): Promise<CloudflareKVResponse> {
try {
const url = `${this.getKVBaseUrl()}/values/${encodeURIComponent(key)}`
console.log(`[CloudflareKV] PUT request to: ${url}`)
const body: any = {
value: typeof value === 'string' ? value : JSON.stringify(value)
}
@@ -68,6 +69,8 @@ export class CloudflareKVClient {
body.metadata = JSON.stringify(metadata)
}
console.log(`[CloudflareKV] PUT body:`, body)
const response = await fetch(url, {
method: 'PUT',
headers: {
@@ -77,8 +80,11 @@ export class CloudflareKVClient {
body: JSON.stringify(body)
})
console.log(`[CloudflareKV] PUT response status: ${response.status}`)
const result = await response.json()
console.log(`[CloudflareKV] PUT response:`, result)
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${result.errors?.[0]?.message || 'Unknown error'}`)
}