traxxx/src/web/tags.js

26 lines
428 B
JavaScript
Raw Normal View History

'use strict';
2020-10-16 21:00:03 +00:00
const { fetchTag, fetchTags } = require('../tags');
2020-10-16 21:00:03 +00:00
async function fetchTagApi(req, res) {
const tag = await fetchTag(req.params.tagId);
2020-10-16 21:00:03 +00:00
if (tag) {
res.send({ tag });
return;
}
2020-10-16 21:00:03 +00:00
res.status(404).send({ tag: null });
}
2020-10-16 21:00:03 +00:00
async function fetchTagsApi(req, res) {
const tags = await fetchTags(req.query.limit);
2020-10-16 21:00:03 +00:00
res.send({ tags });
}
module.exports = {
2020-10-16 21:00:03 +00:00
fetchTag: fetchTagApi,
fetchTags: fetchTagsApi,
};