BunnyService: don't crash if config missing + HybridStorage reads from DB
This commit is contained in:
parent
55df1e27f0
commit
b1d3b77edb
@ -51,6 +51,7 @@ interface BunnyLibraryResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class BunnyService {
|
export class BunnyService {
|
||||||
|
disabled: boolean = false;
|
||||||
private migratedGuids: Set<string> = new Set();
|
private migratedGuids: Set<string> = new Set();
|
||||||
private migratedGuidsRefreshedAt: number = 0;
|
private migratedGuidsRefreshedAt: number = 0;
|
||||||
|
|
||||||
@ -100,7 +101,12 @@ export class BunnyService {
|
|||||||
this.hostname = process.env.BUNNY_HOSTNAME!;
|
this.hostname = process.env.BUNNY_HOSTNAME!;
|
||||||
|
|
||||||
if (!this.apiKey || !this.libraryId || !this.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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1016,11 +1016,11 @@ export class HybridStorage implements IStorage {
|
|||||||
|
|
||||||
// Video operations - use Bunny.net
|
// Video operations - use Bunny.net
|
||||||
async getVideos(limit?: number, offset?: number, search?: string): Promise<Video[]> {
|
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> {
|
async getVideo(id: string): Promise<Video | undefined> {
|
||||||
return this.bunnyStorage.getVideo(id);
|
return this.databaseStorage.getVideo(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
async createVideo(video: InsertVideo): Promise<Video> {
|
async createVideo(video: InsertVideo): Promise<Video> {
|
||||||
@ -1033,11 +1033,11 @@ export class HybridStorage implements IStorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async updateVideoViews(id: string): Promise<void> {
|
async updateVideoViews(id: string): Promise<void> {
|
||||||
return this.bunnyStorage.updateVideoViews(id);
|
return this.databaseStorage.updateVideoViews(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getVideoCount(search?: string): Promise<number> {
|
async getVideoCount(search?: string): Promise<number> {
|
||||||
return this.bunnyStorage.getVideoCount(search);
|
return this.databaseStorage.getVideoCount(search);
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteVideo(id: string): Promise<boolean> {
|
async deleteVideo(id: string): Promise<boolean> {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user