Added release type distinction to REST API.

This commit is contained in:
2020-05-20 01:38:58 +02:00
parent 057362d011
commit b6691e1991
5 changed files with 137 additions and 73 deletions

View File

@@ -1,6 +1,6 @@
'use strict';
const { fetchActor } = require('../actors');
const { fetchActor, searchActors } = require('../actors');
async function fetchActorApi(req, res) {
const actor = await fetchActor(req.params.actorId);
@@ -13,6 +13,20 @@ async function fetchActorApi(req, res) {
res.status(404).send({ actor: null });
}
async function fetchActorsApi(req, res) {
const query = req.query.query || req.query.q;
if (query) {
const actors = await searchActors(query, req.query.limit);
res.send({ actors });
return;
}
res.send({ hint: 'specify a query or ID', actors: [] });
}
module.exports = {
fetchActor: fetchActorApi,
fetchActors: fetchActorsApi,
};