config.js 527 B

12345678910111213141516171819
  1. import { fileURLToPath } from 'url';
  2. import { join } from 'path';
  3. import { readFileSync } from 'fs';
  4. const __filename = fileURLToPath(import.meta.url);
  5. const __dirname = new URL('.', import.meta.url).pathname;
  6. const configPath = join(__dirname, '../../config.json');
  7. let config;
  8. try {
  9. const configContent = readFileSync(configPath, 'utf-8');
  10. config = JSON.parse(configContent);
  11. } catch (error) {
  12. throw new Error(`Failed to load config.json from ${configPath}: ${error.message}`);
  13. }
  14. export default config;