forked from DebaucheryLibrarian/traxxx
32 lines
719 B
JavaScript
32 lines
719 B
JavaScript
'use strict';
|
|
|
|
const { fetchActors } = 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;
|
|
|
|
if (actorId || actorSlug) {
|
|
const actors = await fetchActors({
|
|
id: actorId,
|
|
slug: actorSlug,
|
|
});
|
|
|
|
if (actors.length > 0) {
|
|
res.send(actors[0]);
|
|
return;
|
|
}
|
|
|
|
res.status(404).send();
|
|
return;
|
|
}
|
|
|
|
const actors = await fetchActors(null, req.query.limit);
|
|
|
|
res.send(actors);
|
|
}
|
|
|
|
module.exports = {
|
|
fetchActors: fetchActorsApi,
|
|
};
|