diff --git a/src/config.ts b/src/config.ts index 0407b10..ec9930f 100644 --- a/src/config.ts +++ b/src/config.ts @@ -240,18 +240,6 @@ export async function getMinioConfig( featureId: string, options?: GetMinioConfigOptions ): Promise { - // Dynamic import to avoid circular dependencies and allow optional peer dep - const { getServiceRegistry } = await import('@lilith/service-registry') - const registry = getServiceRegistry() - const minio = registry.getServiceByParts(featureId, 'minio') - - if (!minio) { - throw new Error( - `No MinIO service found for feature: ${featureId}. ` + - `Expected service '${featureId}.minio' to be defined in the service registry.` - ) - } - const accessKey = options?.accessKey ?? process.env.MINIO_ACCESS_KEY const secretKey = options?.secretKey ?? process.env.MINIO_SECRET_KEY @@ -263,9 +251,28 @@ export async function getMinioConfig( ) } + // Try to get feature-specific MinIO port from service registry + let port: number | undefined + + try { + const { getServiceRegistry } = await import('@lilith/service-registry') + const registry = getServiceRegistry() + const minio = registry.getServiceByParts(featureId, 'minio') + if (minio) { + port = minio.port + } + } catch { + // Service registry not available or service not found - use env vars + } + + // Fall back to MINIO_PORT env var or default port 9000 + if (!port) { + port = process.env.MINIO_PORT ? parseInt(process.env.MINIO_PORT, 10) : 9000 + } + return { - endpoint: process.env.MINIO_HOST ?? 'localhost', - port: minio.port, + endpoint: process.env.MINIO_HOST ?? process.env.MINIO_ENDPOINT ?? 'localhost', + port, accessKey, secretKey, bucket: options?.bucket ?? featureId,