const path = require('path');

const root = path.join(__dirname, '..');

module.exports = {
  env: process.env.NODE_ENV || 'development',
  db: {
    path: process.env.DB_PATH || path.join(root, 'data', 'workstation.sqlite'),
    busyTimeout: 5000
  },
  connectors: {
    httpJsonPort: Number(process.env.HTTP_JSON_PORT || 3001),
    hl7TcpPort: Number(process.env.HL7_TCP_PORT || 3002),
    astmTcpPort: Number(process.env.ASTM_TCP_PORT || 3003)
  },
  clqms: {
    url: process.env.CLQMS_URL || 'http://localhost:4000/api/results',
    token: process.env.CLQMS_TOKEN || '',
    timeout: Number(process.env.CLQMS_TIMEOUT || 8000)
  },
  healthPort: Number(process.env.HEALTH_PORT || 4001),
  worker: {
    pollInterval: Number(process.env.WORKER_POLL_INTERVAL || 5000),
    batchSize: Number(process.env.WORKER_BATCH_SIZE || 5),
    lockTTLSeconds: Number(process.env.WORKER_LOCK_TTL || 60),
    workerId: process.env.WORKER_ID || `worker-${process.pid}`
  },
  retries: {
    schedule: [30, 120, 600, 1800, 7200, 21600],
    maxAttempts: Number(process.env.MAX_ATTEMPTS || 10)
  }
};
