From 640bcd82cfa7235b303de2ca80862d977aa99f75 Mon Sep 17 00:00:00 2001 From: sebastjanartic <45803536-sebastjanartic@users.noreply.replit.com> Date: Fri, 8 Aug 2025 18:31:28 +0000 Subject: [PATCH] Integrate Bunny.net for storing user-uploaded videos Update server/storage.ts to prioritize Bunny.net storage if configured, falling back to database or memory storage. Replit-Commit-Author: Agent Replit-Commit-Session-Id: d7424866-83d1-4486-a212-ac12b4c7becf Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/d7424866-83d1-4486-a212-ac12b4c7becf/ESknBgQ --- server/storage.ts | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/server/storage.ts b/server/storage.ts index c471c24..543d2a5 100644 --- a/server/storage.ts +++ b/server/storage.ts @@ -797,9 +797,28 @@ let storage: IStorage; const hasDatabase = process.env.DATABASE_URL; const hasBunnyConfig = process.env.BUNNY_API_KEY && process.env.BUNNY_LIBRARY_ID && process.env.BUNNY_HOSTNAME; -// For now, use memory storage to ensure the backend works properly -// Database implementation is ready but needs proper database setup -console.log('📁 Using memory storage for reliable backend demonstration'); -storage = new MemStorage(); +// Prioritize Bunny.net storage for user's video content +if (hasBunnyConfig) { + try { + storage = new BunnyStorage(); + console.log('✅ Using Bunny.net storage with library ID:', process.env.BUNNY_LIBRARY_ID); + } catch (error) { + console.error('❌ Failed to initialize Bunny.net storage:', error); + console.log('📁 Falling back to memory storage'); + storage = new MemStorage(); + } +} else if (hasDatabase) { + try { + storage = new DatabaseStorage(); + console.log('✅ Using PostgreSQL database storage'); + } catch (error) { + console.error('❌ Failed to initialize database storage:', error); + console.log('📁 Falling back to memory storage'); + storage = new MemStorage(); + } +} else { + console.log('📁 Using memory storage (no database or Bunny.net config found)'); + storage = new MemStorage(); +} export { storage };