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/profileController.js` and assign it to `profileCntl`, 
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', profileCntl.apiName) `, 
Read each API name from the supporting data and dynamically create a route for each, 
For api have id params in the route as in this form `router.post('/endpoint/:taskId', authCtl.apiName)`, 
Export the router using `module.exports = router;` at the end
    - Previous Code 
    - Supporting data 
const mongoose = require('mongoose');
// Assuming the User model is already defined and imported
const User = mongoose.model('User');

// Function to fetch user profile details
exports.getUserProfile = async (userId) => {
  try {
    // Find the user by userId in the database
    const user = await User.findById(userId).select('-password'); // Exclude password from the response

    // Check if user was found
    if (!user) {
      throw new Error('User not found');
    }

    // Return user details
    return {
      success: true,
      data: user,
    };
    
  } catch (error) {
    // Handle errors
    return {
      success: false,
      message: error.message || 'An error occurred while fetching the user profile',
    };
  }
};

// Assuming the User model is already defined and imported
// const User = mongoose.model('User');

// Multer configuration for file upload
const storage = multer.diskStorage({
  destination: function (req, file, cb) {
    cb(null, 'uploads/');
  },
  filename: function (req, file, cb) {
    cb(null, Date.now() + '-' + file.originalname);
  },
});

const upload = multer({ storage: storage });

exports.updateUserProfile = async (req, res) => {
  try {
    const { name, email, phone, profilePicture } = req.body;
    const userId = req.userId; // Assuming userId is extracted from the authenticated user's token

    // Ensure at least one field to update is provided
    if (!name && !email && !phone && !profilePicture) {
      return res.status(400).json({
        success: false,
        message: 'At least one field must be provided for update',
      });
    }

    // Find the user by userId in the database
    const user = await User.findById(userId);

    // Check if user was found
    if (!user) {
      return res.status(404).json({
        success: false,
        message: 'User not found',
      });
    }

    // Update fields
    if (name) user.name = name;
    if (phone) user.phone = phone;
    
    if (email) {
      // Check if the email is already used by another user
      const existingUser = await User.findOne({ email: email });
      if (existingUser && existingUser.id !== userId) {
        return res.status(400).json({
          success: false,
          message: 'Email is already in use by another user',
        });
      }
      user.email = email;
    }

    // Handle profilePicture upload
    if (req.file) {
      user.profilePicture = req.file.path;
    }

    // Save the updated user
    const updatedUser = await user.save();

    // Respond with updated user details (excluding sensitive data like password)
    res.json({
      success: true,
      data: {
        name: updatedUser.name,
        email: updatedUser.email,
        phone: updatedUser.phone,
        profilePicture: updatedUser.profilePicture,
      },
    });
  } catch (error) {
    // Handle errors
    res.status(500).json({
      success: false,
      message: error.message || 'An error occurred while updating the user profile',
    });
  }
};

// Usage of Multer in express routes would require this function to be called with `upload.single('profilePicture')`
// Example:
// app.put('/api/user/profile', upload.single('profilePicture'), updateUserProfile);

// Assuming the User model is already defined and imported
// const User = mongoose.model('User');

exports.changePassword = async (req, res) => {
  try {
    const { oldPassword, newPassword } = req.body;
    const userId = req.userId; // Assuming userId is extracted from the authenticated user's token

    // Validate required fields
    if (!oldPassword || !newPassword) {
      return res.status(400).json({
        success: false,
        message: 'Both old and new passwords are required',
      });
    }

    // Find the user by userId in the database
    const user = await User.findById(userId);

    // Check if user was found
    if (!user) {
      return res.status(404).json({
        success: false,
        message: 'User not found',
      });
    }

    // Compare oldPassword with the stored hashed password
    const isMatch = await bcrypt.compare(oldPassword, user.password);
    if (!isMatch) {
      return res.status(400).json({
        success: false,
        message: 'Incorrect old password',
      });
    }

    // Hash the newPassword
    const hashedPassword = await bcrypt.hash(newPassword, 10);

    // Update the user's password in the database
    user.password = hashedPassword;
    await user.save();

    // Respond with a success message indicating password change
    res.json({
      success: true,
      message: 'Password changed successfully',
    });
  } catch (error) {
    // Handle errors like weak newPassword or database issues
    res.status(500).json({
      success: false,
      message: error.message || 'An error occurred while changing the password',
    });
  }
};

    - 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: