import fs from 'fs/promises'
import yaml from 'js-yaml'
import logger from './logger.js'

export const configMap = {
  urls: [],
  salt: null,
  async load () {
    try {
      const doc = yaml.load(await fs.readFile('./config/config.yaml', 'utf8'))
      this.urls = doc.baseUrls || []
      this.salt = doc.salt
      logger.debug('[Config] Config has been loaded')
    } catch (error) {
      logger.error(`[Config] Error loading configuration: ${error.message}`)
    }
  }
}