2019-11-11 04:18:28 +00:00
|
|
|
'use strict';
|
|
|
|
|
2020-10-16 21:00:03 +00:00
|
|
|
const { fetchTag, fetchTags } = require('../tags');
|
2019-11-11 04:18:28 +00:00
|
|
|
|
2020-10-16 21:00:03 +00:00
|
|
|
async function fetchTagApi(req, res) {
|
|
|
|
const tag = await fetchTag(req.params.tagId);
|
2019-12-01 04:32:47 +00:00
|
|
|
|
2020-10-16 21:00:03 +00:00
|
|
|
if (tag) {
|
|
|
|
res.send({ tag });
|
2020-05-14 02:26:05 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-12-01 04:32:47 +00:00
|
|
|
|
2020-10-16 21:00:03 +00:00
|
|
|
res.status(404).send({ tag: null });
|
|
|
|
}
|
2019-12-04 20:58:08 +00:00
|
|
|
|
2020-10-16 21:00:03 +00:00
|
|
|
async function fetchTagsApi(req, res) {
|
|
|
|
const tags = await fetchTags(req.query.limit);
|
2019-11-11 04:18:28 +00:00
|
|
|
|
2020-10-16 21:00:03 +00:00
|
|
|
res.send({ tags });
|
2019-11-11 04:18:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
2020-10-16 21:00:03 +00:00
|
|
|
fetchTag: fetchTagApi,
|
2020-05-14 02:26:05 +00:00
|
|
|
fetchTags: fetchTagsApi,
|
2019-11-11 04:18:28 +00:00
|
|
|
};
|