import { analyzeInstaller, listInstallerTechnologies } from '../services/installerIntelService.js';
import { buildDetectionRule } from '../services/detectionRuleService.js';

export function installerTypes(req, res) {
  res.json(listInstallerTechnologies());
}

export function analyze(req, res) {
  const fileName = String(req.body?.fileName || '').trim();
  if (!fileName) return res.status(400).json({ error: 'fileName is required' });
  res.json(analyzeInstaller({ fileName, productCode: req.body?.productCode || '' }));
}

export function detection(req, res) {
  try {
    res.json(buildDetectionRule(req.body || {}));
  } catch (error) {
    res.status(400).json({ error: error.message });
  }
}
