MCPcopy Index your code
hub / github.com/Packstack-Tech/packstack / fetchCategory

Function fetchCategory

api/controllers/item.js:92–105  ·  view source on GitHub ↗
(categoryId)

Source from the content-addressed store, hash-verified

90
91// create or retrieve category
92async function fetchCategory(categoryId) {
93 let newCat = null;
94 const category = { name: categoryId, level: 'USER' };
95 try {
96 newCat = await models.Category.create(category);
97 } catch (err) {
98 try {
99 newCat = await models.Category.findOne({ where: { name: categoryId } });
100 } catch (err) {
101 return { newCat: null, err };
102 }
103 }
104 return { category: newCat, err: null };
105}
106
107// Create
108router.post('', authenticate, async (req, res) => {

Callers 1

item.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected