Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
475 B
4
Indexable
Never
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 };
Leave a Comment