const { getLocalDBVersion } = require('../models/dbVersionModel');

async function getDatabaseVersion(req, res) {
  try {
    const version = await getLocalDBVersion();
    if (!version) return res.json({ database_version: 'unknown' });
    res.json({ database_version: version.database_version });
  } catch (err) {
    console.error('Failed to fetch DB version:', err);
    res.status(500).json({ error: 'Failed to fetch database version' });
  }
}

module.exports = { getDatabaseVersion };
