Files
paperclip/server/src/storage/index.ts
Forgotten fdd2ea6157 feat: add storage system with local disk and S3 providers
Introduces a provider-agnostic storage subsystem for file attachments.
Includes local disk and S3 backends, asset/attachment DB schemas, issue
attachment CRUD routes with multer upload, CLI configure/doctor/env
integration, and enriched issue ancestors with project/goal resolution.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 10:31:56 -06:00

36 lines
1.2 KiB
TypeScript

import { loadConfig, type Config } from "../config.js";
import { createStorageProviderFromConfig } from "./provider-registry.js";
import { createStorageService } from "./service.js";
import type { StorageService } from "./types.js";
let cachedStorageService: StorageService | null = null;
let cachedSignature: string | null = null;
function signatureForConfig(config: Config): string {
return JSON.stringify({
provider: config.storageProvider,
localDisk: config.storageLocalDiskBaseDir,
s3Bucket: config.storageS3Bucket,
s3Region: config.storageS3Region,
s3Endpoint: config.storageS3Endpoint,
s3Prefix: config.storageS3Prefix,
s3ForcePathStyle: config.storageS3ForcePathStyle,
});
}
export function createStorageServiceFromConfig(config: Config): StorageService {
return createStorageService(createStorageProviderFromConfig(config));
}
export function getStorageService(): StorageService {
const config = loadConfig();
const signature = signatureForConfig(config);
if (!cachedStorageService || cachedSignature !== signature) {
cachedStorageService = createStorageServiceFromConfig(config);
cachedSignature = signature;
}
return cachedStorageService;
}
export type { StorageService, PutFileResult } from "./types.js";