traxxx/src/web/releases.js

34 lines
1.0 KiB
JavaScript
Raw Normal View History

'use strict';
const { fetchReleases, fetchNetworkReleases, fetchSiteReleases } = require('../releases');
async function fetchReleasesApi(req, res) {
const releases = await fetchReleases(req.params.releaseId);
2019-05-18 23:34:08 +00:00
res.send(releases);
2019-05-18 23:34:08 +00:00
}
async function fetchNetworkReleasesApi(req, res) {
const networkId = typeof req.params.networkId === 'number' ? req.params.networkId : null;
const networkSlug = typeof req.params.networkId === 'string' ? req.params.networkId : null;
const releases = await fetchNetworkReleases(networkId, networkSlug);
res.send(releases);
}
async function fetchSiteReleasesApi(req, res) {
const siteId = typeof req.params.siteId === 'number' ? req.params.siteId : null;
const siteSlug = typeof req.params.siteId === 'string' ? req.params.siteId : null;
const releases = await fetchSiteReleases(siteId, siteSlug);
res.send(releases);
}
module.exports = {
fetchReleases: fetchReleasesApi,
fetchNetworkReleases: fetchNetworkReleasesApi,
fetchSiteReleases: fetchSiteReleasesApi,
};