UNPKG

@gramio/storage-cloudflare

Version:

Cloudflare KV Storage for GramIO

28 lines (25 loc) 557 B
'use strict'; function cloudflareStorage(kv) { return { get: async (key) => { const value = await kv.get(key, "json"); return value ?? void 0; }, set: async (key, value) => { await kv.put(key, JSON.stringify(value)); }, has: async (key) => { const value = await kv.get(key); return value !== null; }, delete: async (key) => { try { await kv.delete(key); return true; } catch { return false; } } }; } exports.cloudflareStorage = cloudflareStorage;