Added basic release and actor API.
This commit is contained in:
@@ -1,31 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
const { fetchActors } = require('../actors');
|
||||
const { fetchActor } = require('../actors');
|
||||
|
||||
async function fetchActorsApi(req, res) {
|
||||
const actorId = typeof req.params.actorId === 'number' ? req.params.actorId : null;
|
||||
const actorSlug = typeof req.params.actorId === 'string' ? req.params.actorId : null;
|
||||
async function fetchActorApi(req, res) {
|
||||
const actor = await fetchActor(req.params.actorId);
|
||||
|
||||
if (actorId || actorSlug) {
|
||||
const actors = await fetchActors({
|
||||
id: actorId,
|
||||
slug: actorSlug,
|
||||
});
|
||||
|
||||
if (actors.length > 0) {
|
||||
res.send(actors[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
res.status(404).send();
|
||||
if (actor) {
|
||||
res.send({ actor });
|
||||
return;
|
||||
}
|
||||
|
||||
const actors = await fetchActors(null, req.query.limit);
|
||||
|
||||
res.send(actors);
|
||||
res.status(404).send({ actor: null });
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
fetchActors: fetchActorsApi,
|
||||
fetchActor: fetchActorApi,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user