import Product from "../models/Product.js";

export const createProduct = async (req,res) => {
    try{
const product = await Product.create(req.body);
res.status(201).json(product);
    }catch(error){
res.status(500).json({message:error.message});
    }
};


export const getAllProduct = async (req,res) => {
    try{
const product = await Product.find()
res.status(200).json(product)
    }catch(error){
res.status(500).json({message:error.message});
    }
};

export const getProduct = async (req,res) => {
    try{
const product = await Product.findById(req.params.id);
res.status(200).json(product);
    }catch(error){
res.status(500).json({message:error.message});
    }
};

 