2019-05-06 00:01:57 +00:00
|
|
|
'use strict';
|
|
|
|
|
2019-11-10 03:20:22 +00:00
|
|
|
const {
|
|
|
|
fetchReleases,
|
|
|
|
fetchActorReleases,
|
|
|
|
fetchNetworkReleases,
|
|
|
|
fetchSiteReleases,
|
2019-11-11 04:18:28 +00:00
|
|
|
fetchTagReleases,
|
2019-11-10 03:20:22 +00:00
|
|
|
} = require('../releases');
|
2019-05-06 00:01:57 +00:00
|
|
|
|
|
|
|
async function fetchReleasesApi(req, res) {
|
2019-11-15 01:37:17 +00:00
|
|
|
const releases = await fetchReleases({}, req.query);
|
2019-05-18 23:34:08 +00:00
|
|
|
|
2019-06-03 03:31:38 +00:00
|
|
|
res.send(releases);
|
2019-05-18 23:34:08 +00:00
|
|
|
}
|
|
|
|
|
2019-11-15 00:27:58 +00:00
|
|
|
async function fetchReleaseByIdApi(req, res) {
|
|
|
|
const [release] = await fetchReleases({
|
|
|
|
id: req.params.releaseId,
|
|
|
|
});
|
|
|
|
|
|
|
|
res.send(release);
|
|
|
|
}
|
|
|
|
|
2019-11-10 03:20:22 +00:00
|
|
|
async function fetchActorReleasesApi(req, res) {
|
|
|
|
const actorId = Number.isInteger(Number(req.params.actorId)) ? Number(req.params.actorId) : null;
|
|
|
|
const actorSlug = typeof req.params.actorId === 'string' ? req.params.actorId : null;
|
|
|
|
|
2019-11-15 00:27:58 +00:00
|
|
|
const releases = await fetchActorReleases({
|
|
|
|
id: actorId,
|
|
|
|
slug: actorSlug,
|
2019-11-15 04:10:59 +00:00
|
|
|
}, req.query);
|
2019-11-10 03:20:22 +00:00
|
|
|
|
|
|
|
res.send(releases);
|
|
|
|
}
|
|
|
|
|
2019-11-09 03:43:58 +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;
|
|
|
|
|
2019-11-15 00:27:58 +00:00
|
|
|
const releases = await fetchNetworkReleases({
|
|
|
|
id: networkId,
|
|
|
|
slug: networkSlug,
|
2019-11-15 01:37:17 +00:00
|
|
|
}, req.query);
|
2019-11-09 03:43:58 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2019-11-15 00:27:58 +00:00
|
|
|
const releases = await fetchSiteReleases({
|
|
|
|
id: siteId,
|
|
|
|
slug: siteSlug,
|
2019-11-15 04:10:59 +00:00
|
|
|
}, req.query);
|
2019-11-09 03:43:58 +00:00
|
|
|
|
|
|
|
res.send(releases);
|
|
|
|
}
|
|
|
|
|
2019-11-11 04:18:28 +00:00
|
|
|
async function fetchTagReleasesApi(req, res) {
|
|
|
|
const tagId = typeof req.params.tagId === 'number' ? req.params.tagId : null;
|
|
|
|
const tagSlug = typeof req.params.tagId === 'string' ? req.params.tagId : null;
|
|
|
|
|
2019-11-15 00:27:58 +00:00
|
|
|
const releases = await fetchTagReleases({
|
|
|
|
id: tagId,
|
|
|
|
slug: tagSlug,
|
2019-11-15 04:10:59 +00:00
|
|
|
}, req.query);
|
2019-11-11 04:18:28 +00:00
|
|
|
|
|
|
|
res.send(releases);
|
|
|
|
}
|
|
|
|
|
2019-05-06 00:01:57 +00:00
|
|
|
module.exports = {
|
|
|
|
fetchReleases: fetchReleasesApi,
|
2019-11-15 00:27:58 +00:00
|
|
|
fetchReleaseById: fetchReleaseByIdApi,
|
2019-11-10 03:20:22 +00:00
|
|
|
fetchActorReleases: fetchActorReleasesApi,
|
2019-11-09 03:43:58 +00:00
|
|
|
fetchNetworkReleases: fetchNetworkReleasesApi,
|
|
|
|
fetchSiteReleases: fetchSiteReleasesApi,
|
2019-11-11 04:18:28 +00:00
|
|
|
fetchTagReleases: fetchTagReleasesApi,
|
2019-05-06 00:01:57 +00:00
|
|
|
};
|