BunnyService: don't crash if config missing + HybridStorage reads from DB

This commit is contained in:
Sebastjan 2026-06-09 00:09:06 +02:00
parent 55df1e27f0
commit b1d3b77edb
2 changed files with 11 additions and 5 deletions

View File

@ -51,6 +51,7 @@ interface BunnyLibraryResponse {
}
export class BunnyService {
disabled: boolean = false;
private migratedGuids: Set<string> = new Set();
private migratedGuidsRefreshedAt: number = 0;
@ -100,7 +101,12 @@ export class BunnyService {
this.hostname = process.env.BUNNY_HOSTNAME!;
if (!this.apiKey || !this.libraryId || !this.hostname) {
throw new Error("Missing Bunny.net configuration");
console.warn("⚠️ Missing Bunny.net configuration — BunnyService running in disabled mode (uses DB-only)");
this.disabled = true;
this.apiKey = "";
this.libraryId = "";
this.cdnHostname = "";
return;
}
}

View File

@ -1016,11 +1016,11 @@ export class HybridStorage implements IStorage {
// Video operations - use Bunny.net
async getVideos(limit?: number, offset?: number, search?: string): Promise<Video[]> {
return this.bunnyStorage.getVideos(limit, offset, search);
return this.databaseStorage.getVideos(limit, offset, search);
}
async getVideo(id: string): Promise<Video | undefined> {
return this.bunnyStorage.getVideo(id);
return this.databaseStorage.getVideo(id);
}
async createVideo(video: InsertVideo): Promise<Video> {
@ -1033,11 +1033,11 @@ export class HybridStorage implements IStorage {
}
async updateVideoViews(id: string): Promise<void> {
return this.bunnyStorage.updateVideoViews(id);
return this.databaseStorage.updateVideoViews(id);
}
async getVideoCount(search?: string): Promise<number> {
return this.bunnyStorage.getVideoCount(search);
return this.databaseStorage.getVideoCount(search);
}
async deleteVideo(id: string): Promise<boolean> {