// src/config/index.js
//
// This module should ONLY load NON-SENSITIVE configuration.
// All secrets must come from environment variables (see src/config/secrets.js).
//
// Do NOT put real credentials in any file under /config.

import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

// This file should contain only non-secret settings (server name, default port, etc.)
const configPath = path.join(__dirname, '../../config/config.json');

let configData;
try {
  const raw = fs.readFileSync(configPath, 'utf8');
  configData = JSON.parse(raw);
} catch (err) {
  console.error(`Failed to load config from ${configPath}:`, err.message);
  // Non-secret config is optional — continue with empty object
  configData = {};
}

export default configData;