All files config.js

100% Statements 4/4
100% Branches 0/0
100% Functions 0/0
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54                                  3x 3x         3x                                                       3x    
'use strict';
 
/**
 * Runtime configuration schema for @onlineapps/conn-base-storage.
 *
 * Uses @onlineapps/runtime-config for unified priority:
 * 1. Explicit config (passed to constructor)
 * 2. Environment variable
 * 3. Owner defaults (from ./defaults.js)
 *
 * NOTE:
 * This module resolves MinIO runtime configuration via @onlineapps/runtime-config
 * to avoid inline process.env access in implementation code.
 *
 * @module @onlineapps/conn-base-storage/config
 */
 
const { createRuntimeConfig } = require('@onlineapps/runtime-config');
const DEFAULTS = require('./defaults');
 
/**
 * Runtime config schema for StorageConnector
 */
const runtimeCfg = createRuntimeConfig({
  defaults: DEFAULTS,
  schema: {
    // MinIO topology (FAIL-FAST)
    // Keep key names aligned with constructor config for predictability.
    endPoint: { env: 'MINIO_ENDPOINT', required: true },
    port: { env: 'MINIO_PORT', required: true, type: 'number' },
    useSSL: { env: 'MINIO_USE_SSL', default: false, type: 'boolean' },
    accessKey: { env: 'MINIO_ACCESS_KEY', required: true },
    secretKey: { env: 'MINIO_SECRET_KEY', required: true },
 
    // Wrapper behavior (module-owned defaults)
    logLevel: { env: 'STORAGE_LOG_LEVEL', defaultKey: 'logLevel' },
    defaultBucket: { env: 'MINIO_DEFAULT_BUCKET', defaultKey: 'defaultBucket' },
    bucketName: { defaultKey: 'bucketName' },
    cacheMaxSize: { defaultKey: 'cacheMaxSize', type: 'number' },
    maxCacheSize: { defaultKey: 'maxCacheSize', type: 'number' },
 
    // InternalUrlAdapter behavior (module-owned defaults + env hints)
    nodeEnv: { env: 'NODE_ENV', default: 'development' },
    dockerNetwork: { env: 'DOCKER_NETWORK', default: false, type: 'boolean' },
    dockerEnv: { env: 'DOCKER_ENV' },
    dockerContainer: { env: 'DOCKER_CONTAINER' },
    hostname: { env: 'HOSTNAME' },
    internalUrlServiceMap: { defaultKey: 'internalUrlServiceMap' },
  }
});
 
module.exports = runtimeCfg;