@mixio-pro/kalaasetu-mcp
Version:
A powerful Model Context Protocol server providing AI tools for content generation and analysis
32 lines (25 loc) • 925 B
text/typescript
import type { StorageProvider } from "./interface";
import { LocalStorageProvider } from "./local";
import { GCSStorageProvider } from "./gcs";
let storageInstance: StorageProvider | null = null;
export function getStorage(): StorageProvider {
if (!storageInstance) {
const type = process.env.STORAGE_PROVIDER || "local";
console.error(`Initializing storage provider: ${type}`);
console.error(`Base path (cwd): ${process.cwd()}`);
if (type === "gcs") {
const bucket = process.env.GCS_BUCKET;
if (!bucket) {
throw new Error("GCS_BUCKET is required when using gcs storage");
}
storageInstance = new GCSStorageProvider(bucket);
} else {
storageInstance = new LocalStorageProvider(process.cwd());
}
// Initialize async
storageInstance
.init()
.catch((err) => console.error("Failed to init storage:", err));
}
return storageInstance;
}