Untitled
unknown
plain_text
2 years ago
485 B
12
Indexable
//exemplo
const { Category } = require('../models');
const createCategory = async (req, res) => {
const { name } = req.body;
if (!name) return res.status(400).json({ message: '"name" is required' });
const category = await Category.create({ name });
res.status(201).json(category);
};
const findAllCategories = async (_req, res) => {
const categories = await Category.findAll();
res.status(200).json(categories);
};
module.exports = { createCategory, findAllCategories };Editor is loading...
Leave a Comment