๐Ÿ—ƒ๏ธ Storage Binding Configuration Guide

Cloudflare Workers Storage Integration - Complete Setup Guide

This guide provides step-by-step instructions to configure storage bindings for all 10 workers, improving integration health from 70% to 100%.


๐Ÿ“‹ Table of Contents

๐ŸŽฏ Quick Start

โš™๏ธ Configuration

๐Ÿ”ง Implementation & Testing

๐Ÿš€ Next Steps


๐Ÿ“Š Storage Binding Overview

Current Status: 7/10 workers configured (70%)
Target Status: 10/10 workers configured (100%)

Missing Bindings: 3 critical workers


๐Ÿš€ Quick Setup Commands

Step 1: Create Missing Storage Resources

# Create any missing KV namespaces
bun run cf kv create apex-api-cache
bun run cf kv create apex-sessions
bun run cf kv create apex-dashboard-cache

# Create any missing D1 databases
bun run cf d1 create apex-users
bun run cf d1 create apex-analytics
bun run cf d1 create apex-logs
bun run cf d1 create apex-messages

# Create any missing R2 buckets
bun run cf r2 create apex-blog-assets
bun run cf r2 create apex-packages

Step 2: Apply Generated Configurations

The previous tool generated complete wrangler.toml configurations. Apply them to each worker:

  1. Navigate to worker directory
  2. Copy appropriate configuration
  3. Update worker-specific paths
  4. Deploy with new bindings

โš™๏ธ Worker-by-Worker Configuration

1. ๐Ÿ”ฅ apex-api (Priority: HIGH)

Service: Core API
Bindings Required: 3

# Navigate to apex-api worker directory
cd workers/apex-api  # or appropriate path

# Copy configuration from generated output
# Update wrangler.toml with:
# - KV: API_CACHE โ†’ apex-api-cache
# - KV: SESSIONS โ†’ apex-sessions  
# - D1: USERS_DB โ†’ apex-users

# Deploy with new bindings
bun wrangler deploy

2. ๐Ÿ”ฅ apex-auth (Priority: HIGH)

Service: Authentication
Bindings Required: 2

# Navigate to apex-auth worker directory
cd workers/apex-auth  # or appropriate path

# Update wrangler.toml with:
# - KV: AUTH_SESSIONS โ†’ apex-sessions
# - D1: USERS_DB โ†’ apex-users

# Deploy with new bindings
bun wrangler deploy

3. ๐Ÿ”ฅ apexodds-vip (Priority: HIGH)

Service: VIP Services
Bindings Required: 2

# Navigate to apexodds-vip worker directory
cd workers/apexodds-vip  # or appropriate path

# Update wrangler.toml with:
# - D1: USERS_DB โ†’ apex-users
# - D1: ANALYTICS_DB โ†’ apex-analytics

# Deploy with new bindings
bun wrangler deploy

๐Ÿ“ Generated Configuration Templates

๐Ÿ”ง Template 1: KV + D1 Binding (apex-api)

name = "apex-api"
compatibility_date = "2024-01-15"
main = "src/index.js"

[[kv_namespaces]]
binding = "API_CACHE"
id = "apex-api-cache-id"  # Replace with actual ID

[[kv_namespaces]]
binding = "SESSIONS"
id = "apex-sessions-id"  # Replace with actual ID

[[d1_databases]]
binding = "USERS_DB"
database_name = "apex-users"
database_id = "apex-users-uuid"  # Replace with actual ID

๐Ÿ”ง Template 2: Multi-Database Binding (apexodds-vip)

name = "apexodds-vip"
compatibility_date = "2024-01-15"
main = "src/index.js"

[[d1_databases]]
binding = "USERS_DB"
database_name = "apex-users"
database_id = "apex-users-uuid"  # Replace with actual ID

[[d1_databases]]
binding = "ANALYTICS_DB"  
database_name = "apex-analytics"
database_id = "apex-analytics-uuid"  # Replace with actual ID

๐Ÿ”ง Template 3: R2 + KV Binding (apex-blog)

name = "apex-blog"
compatibility_date = "2024-01-15"
main = "src/index.js"

[[kv_namespaces]]
binding = "BLOG_CONTENT"
id = "apex-blog-content-id"  # Replace with actual ID

[[r2_buckets]]
binding = "BLOG_ASSETS"
bucket_name = "apex-blog-assets"

โš™๏ธ Configuration Steps

๐Ÿ“‹ Step 1: Get Resource IDs

# Get KV namespace IDs
bun run cf kv list

# Get D1 database IDs  
bun run cf d1 list

# Get R2 bucket names
bun run cf r2 list

๐Ÿ“‹ Step 2: Update Worker Configurations

For each worker:

  1. Locate wrangler.toml file
  2. Add binding configuration
  3. Replace placeholder IDs with actual IDs
  4. Verify configuration syntax

๐Ÿ“‹ Step 3: Deploy Workers

# Test configuration first
bun wrangler deploy --dry-run

# Deploy with new bindings
bun wrangler deploy

# Verify deployment
bun wrangler tail  # Check for errors

๐Ÿ“‹ Step 4: Verify Bindings

# Check integration health after each deployment
bun run cf scan

# Expected: Storage binding percentage should increase

๐ŸŽฏ Expected Improvements

๐Ÿ“ˆ After Configuring All Storage Bindings:

Before:

After:

๐Ÿš€ Performance Benefits:


๐Ÿšจ Troubleshooting

๐Ÿ” Common Issues:

โŒ 1. Resource Not Found

# Create missing resource first
bun run cf kv create resource-name

โŒ 2. Permission Errors

# Check API permissions
bun tools/diagnostics/apex-diagnostics.ts permissions

โŒ 3. Binding Conflicts

# Remove conflicting bindings from wrangler.toml
# Deploy clean configuration

โŒ 4. Deployment Failures

# Check wrangler.toml syntax
bun wrangler deploy --dry-run

# View detailed errors
bun wrangler tail

โœ… Verification Commands

After configuration:

# Check overall integration health
bun run cf scan

# Verify specific worker bindings
bun wrangler dev --local  # Test locally first

# Check storage binding status  
bun run cf kv list

# Test worker functionality
curl https://apex-api.workers.dev/health
curl https://apexodds-vip.workers.dev/status

๐Ÿš€ Next Steps

๐Ÿ“‹ After Storage Binding Configuration:

  1. DNS Configuration: Complete manual DNS setup
  2. Integration Testing: Verify all services work together
  3. Monitoring Setup: Enable continuous health monitoring
  4. Performance Optimization: Monitor and optimize bindings

๐Ÿ“Š Integration Health Goals

๐ŸŽฏ Target Metrics After Full Configuration:


๐Ÿ“ž Support & Resources

๐Ÿ”ง Health Check: bun run cf scan
๐Ÿ“š Full Guide: bun run cf --help
๐Ÿšจ Troubleshooting: Use integration health check for status updates
๐Ÿ“Š Monitoring: Real-time binding status and performance metrics


๐Ÿ“… Last Updated: August 11, 2025
๐ŸŽฏ Target: 100% Storage Binding Integration
โœ… Status: Ready for Implementation