Untitled

 avatar
unknown
plain_text
a year ago
490 B
4
Indexable
const { getAllProductsDataBase, getProductsById } = require('../models/products');

const allProducts = async () => {
  const itens = await getAllProductsDataBase();
  return { status: 200, data: itens };
};

const productsByID = async (id) => {
  const item = await getProductsById(id);
  if (!item || item.length === 0) {
    return { status: 404, data: { message: 'Product not found' } };
  }
  return { status: 200, data: item };
};

module.exports = {
  allProducts,
  productsByID,
};
Editor is loading...
Leave a Comment