User: Task: "Create Router for APIs"
    Description: "Generate router code that includes POST method endpoints for each given API"
    Requirements:
    - Database: mongoose
    - Authentication: None specified
    - Output needed: Return only the function code as specified in dependencies
    - Dependencies: Import the express module using `const express = require('express');`, 
Import the controller file from `../controllers/productController.js` and assign it to `prodectCntl`, 
Initialize the router using `const router = express.Router();`, 
For each API endpoint name provided in the supporting data, create a POST route in the form `router.post('/endpoint', prodectCntl.apiName) `, 
Read each API name from the supporting data and dynamically create a route for each, 
For deleteProdcut and updateProdic api have id params in the route as in this form `router.post('/endpoint/:prodId', prodectCntl.apiName)`, 
Export the router using `module.exports = router;` at the end
    - Previous Code 
    - Supporting data 
const Product = require('../models/Product.js');

exports.getProductListing = async (req, res) => {
    try {
        // Fetch all products from the database using the Product schema
        const products = await Product.find();

        // Check if no products were found
        if (!products.length) {
            return res.status(200).json({ status: 200, products: [] });
        }

        // Return the products with a status of 200
        return res.status(200).json({ status: 200, products });
    } catch (error) {
        // Handle errors and send a server error status
        return res.status(500).json({ status: 500, error: 'Server Error' });
    }
};

exports.insertProduct = async (req, res) => {
    try {
        // Destructuring product details from the request body
        const { name, description, expiryDate, price, totalItems, insertionDate } = req.body;

        // Validate product details
        if (!name || !description || !expiryDate || !price || !totalItems) {
            return res.status(400).json({ status: 400, error: 'All product details must be provided' });
        }

        // Initialize a new product instance (assuming Product is a mongoose model exposed via schema)
        const product = new Product({
            name,
            description,
            expiryDate,
            price,
            totalItems,
            insertionDate: insertionDate || new Date() // Optional, defaults to current date if not provided
        });

        // Save the product to the database
        const savedProduct = await product.save();

        // Send back a successful response with the saved product
        return res.status(200).json({ status: 200, product: savedProduct });
    } catch (error) {
        // Handle any errors that may occur
        return res.status(500).json({ status: 500, error: 'Error inserting product' });
    }
};

exports.updateProduct = async (req, res) => {
    const proId = req.params.proId;
    const { name, description, expiryDate, price, totalItems } = req.body;

    try {
        // Check if no update values are provided
        if (!name && !description && !expiryDate && !price && !totalItems) {
            return res.status(400).json({ status: 400, error: 'No update fields provided' });
        }

        // Constructing the update object dynamically based on provided fields
        const updateData = {};
        if (name) updateData.name = name;
        if (description) updateData.description = description;
        if (expiryDate) updateData.expiryDate = expiryDate;
        if (price) updateData.price = price;
        if (totalItems) updateData.totalItems = totalItems;

        // Update the product using the Product schema and the product ID
        const updatedProduct = await Product.findByIdAndUpdate(proId, updateData, { new: true });

        // Check if the product was not found
        if (!updatedProduct) {
            return res.status(404).json({ status: 404, error: 'Product not found' });
        }

        // Send back a successful response with the updated product
        return res.status(200).json({ status: 200, product: updatedProduct });
    } catch (error) {
        // Handle any errors that may occur
        return res.status(500).json({ status: 500, error: 'Error updating product' });
    }
};

exports.deleteProduct = async (req, res) => {
    const proId = req.params.proId;

    try {
        // Attempt to delete the product with the given ID using mongoose model
        const deletedProduct = await Product.findByIdAndDelete(proId);

        // If no product is found, send a 404 not found response
        if (!deletedProduct) {
            return res.status(404).json({ status: 404, error: 'Product not found' });
        }

        // If the product is found and deleted successfully, return a 200 response with the deleted product
        return res.status(200).json({ status: 200, product: deletedProduct });
    } catch (error) {
        // Handle any errors that might occur during the process
        return res.status(500).json({ status: 500, error: 'Error deleting product' });
    }
};

    - Updating File undefined
    
    Please generate the code for this task, following the instructions and including comments for clarity.
    While creating router for specifict file your have to read supporing file data and create for that 

    **Output Formats**: 

Return dependencies like this `const bcrypt = require('bcrypt');`  in this formate
```dependencies
const bcrypt = require('bcrypt');
```

Ensure this format is consistently followed in responses.
    
User: 


    
Assistant: