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
This commit is contained in:
sebastjanartic 2025-08-08 18:31:28 +00:00
parent 257e16e8d2
commit 640bcd82cf

View File

@ -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 };