'use strict';

const { fetchSites, fetchSitesFromReleases } = require('../sites');

async function fetchSitesApi(req, res) {
    const siteId = typeof req.params.siteId === 'number' ? req.params.siteId : undefined;
    const siteSlug = typeof req.params.siteId === 'string' ? req.params.siteId : undefined;

    const sites = await fetchSites({
        id: siteId,
        slug: siteSlug,
    });

    res.send(sites);
}

async function fetchSitesFromReleasesApi(req, res) {
    const sites = await fetchSitesFromReleases();

    res.send(sites);
}

module.exports = {
    fetchSites: fetchSitesApi,
    fetchSitesFromReleases: fetchSitesFromReleasesApi,
};
