foix
This commit is contained in:
parent
a5381e5305
commit
855a3bc757
|
|
@ -7,7 +7,7 @@
|
|||
import { CloudflareKVClient, cloudflareKV } from './cloudflareKV'
|
||||
|
||||
// Example 1: Using the default instance
|
||||
export async function basicUsageExample() {
|
||||
async function basicUsageExample() {
|
||||
try {
|
||||
// Store a simple string value
|
||||
await cloudflareKV.put('user:123', 'John Doe')
|
||||
|
|
@ -47,7 +47,7 @@ export async function basicUsageExample() {
|
|||
}
|
||||
|
||||
// Example 2: Using a custom configuration
|
||||
export async function customConfigExample() {
|
||||
async function customConfigExample() {
|
||||
const customKV = new CloudflareKVClient({
|
||||
// You can override any configuration values
|
||||
apiKey: 'your-custom-api-key',
|
||||
|
|
@ -64,7 +64,7 @@ export async function customConfigExample() {
|
|||
}
|
||||
|
||||
// Example 3: Batch operations
|
||||
export async function batchOperationsExample() {
|
||||
async function batchOperationsExample() {
|
||||
try {
|
||||
// Store multiple values at once
|
||||
const entries = [
|
||||
|
|
@ -88,7 +88,7 @@ export async function batchOperationsExample() {
|
|||
}
|
||||
|
||||
// Example 4: Working with metadata
|
||||
export async function metadataExample() {
|
||||
async function metadataExample() {
|
||||
try {
|
||||
const value = { content: 'Important data' }
|
||||
const metadata = {
|
||||
|
|
@ -109,7 +109,7 @@ export async function metadataExample() {
|
|||
}
|
||||
|
||||
// Example 5: Error handling and edge cases
|
||||
export async function errorHandlingExample() {
|
||||
async function errorHandlingExample() {
|
||||
try {
|
||||
// Try to get a non-existent key
|
||||
const nonExistent = await cloudflareKV.get('does-not-exist')
|
||||
|
|
@ -134,7 +134,7 @@ export async function errorHandlingExample() {
|
|||
}
|
||||
|
||||
// Example 6: Video template storage use case
|
||||
export async function videoTemplateStorageExample() {
|
||||
async function videoTemplateStorageExample() {
|
||||
try {
|
||||
const templateData = {
|
||||
id: 'template-001',
|
||||
|
|
@ -182,7 +182,7 @@ export async function videoTemplateStorageExample() {
|
|||
}
|
||||
|
||||
// Run all examples
|
||||
export async function runAllExamples() {
|
||||
async function runAllExamples() {
|
||||
console.log('🚀 Running Cloudflare KV Examples...\n')
|
||||
|
||||
console.log('1. Basic Usage Example:')
|
||||
|
|
@ -219,5 +219,6 @@ export {
|
|||
batchOperationsExample,
|
||||
metadataExample,
|
||||
errorHandlingExample,
|
||||
videoTemplateStorageExample
|
||||
videoTemplateStorageExample,
|
||||
runAllExamples
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue