/** * Storage path helper. * * Historically this module also exported a top-level `minioClient`, * `ensureBucket()`, and `getPresignedUrl()` that read MINIO_* env vars * eagerly at import-time. That broke the Next.js production build * (the route-data collection phase imports route modules transitively, * and modules touching `env.MINIO_*` blew up under SKIP_ENV_VALIDATION * with `InvalidEndpointError: Invalid endPoint : undefined`). * * Storage config now lives in `system_settings` rows and is read at * runtime by the pluggable backend in `@/lib/storage` (see * `getStorageBackend()` and `presignDownloadUrl()`). Build-time env * vars are no longer the source of truth. * * The only piece worth keeping in the legacy module path was this pure * `buildStoragePath` helper, which doesn't touch env at all and is * imported by several services. Everything else has been deleted. */ /** * Constructs a storage path from typed components. * * Format: `{portSlug}/{entity}/{entityId}/{fileId}.{extension}` * * No user-supplied input should ever be used as path components - only * UUIDs and controlled slugs (SECURITY-GUIDELINES.md §3.4, §7.1). */ export function buildStoragePath( portSlug: string, entity: string, entityId: string, fileId: string, extension: string, ): string { return `${portSlug}/${entity}/${entityId}/${fileId}.${extension}`; }