User:  
1  prodect create api 

				Code : // Import necessary modules
const mongoose = require('mongoose');
const Product = require('../models/Product');

// Function to create a new product
const createProduct = async (req, res) => {
    try {

        // Validate provided fields
        const {
            name,
            description,
            stocks,
            countTotal,
            company_name
        } = req.body;

        if (!name || typeof name !== 'string') {
            return res.status(400).json({
                error: 'Invalid name'
            });
        }
        if (!description || typeof description !== 'string') {
            return res.status(400).json({
                error: 'Invalid description'
            });
        }
        if (typeof stocks !== 'number' || stocks < 0) {
            return res.status(400).json({
                error: 'Invalid stocks'
            });
        }
        if (typeof countTotal !== 'number' || countTotal < 0) {
            return res.status(400).json({
                error: 'Invalid total count'
            });
        }
        if (!company_name || !mongoose.Types.ObjectId.isValid(company_name)) {
            return res.status(400).json({
                error: 'Invalid company ID'
            });
        }

        // Create a new product object
        const product = new Product({
            name,
            description,
            stocks,
            countTotal,
            company_name
        });

        // Insert product data into the database
        const savedProduct = await product.save();

        // Send a JSON response with inserted product data
        res.status(201).json(savedProduct);
    } catch (error) {
        res.status(500).json({
            error: 'Server error'
        });
    }



};
User:  
2  product update api 

				Code : const updateProduct = async (req, res) => {
    const {
        productId,
        name,
        description,
        stocks,
        availability,
        countTotal,
        company_name
    } = req.body;

    // Validate input data
    if (!productId || !name || !description || stocks === undefined || countTotal === undefined || !company_name) {
        return res.status(400).json({
            message: 'All fields are required.'
        });
    }

    try {
        // Query the database to find the existing product
        const product = await Product.findById(productId);
        if (!product) {
            return res.status(404).json({
                message: 'Product not found.'
            });
        }

        // Update the product information
        product.name = name;
        product.description = description;
        product.stocks = stocks;
        product.availability = availability;
        product.countTotal = countTotal;
        product.company_name = company_name;

        // Save the updated product
        const updatedProduct = await product.save();

        // Send a response back to the user
        res.status(200).json(updatedProduct);
    } catch (error) {
        // Handle errors appropriately
        console.error(error);
        res.status(500).json({
            message: 'Server error.'
        });
    }
};

module.exports = {
    createProduct,
    updateProduct
};
User: 

		 {description:Define prodect routes for POST, GET, PUT, PATCH, and DELETE methods., 
Implement validation for incoming request data., 
Handle request and response objects appropriately., 
Implement error handling for each operation.
read below apis and create router for all apis  }
	
		 Analyse above object generate source code for description and send response as only a json_object
		 {
  "name": "prompt_name",
  "schema": {
    "type": "string",
	"code":"genarted code"
	"require":"extracted external modules or libraries like const bcrypt = require('bcrypt');"
	}
	}
		
Assistant: