User:  
1  Use this middleware to checkUserRole, apply for all routes 

	Code : const jwt = require('jsonwebtoken');
const mongoose = require('mongoose');
// Import the User schema from models
const User = require('../models/User.js');

// Create middleware function to check user roles
exports.checkUserRole = (roles) => {
    return async (req, res, next) => {

        // Get the token from the request headers
        const token = req.headers.authorization.split(' ')[1];

        if (!token) {
            return res.status(401).json({ message: "No token provided." });
        }

        try {
            // Use JWT to decode token and retrieve user information
            const decoded = jwt.verify(token, 'your_jwt_secret');

            // Fetch the user from the database
            const user = await User.findById(decoded.id);

            if (!user) {
                return res.status(404).json({ message: "User not found." });
            }

            // Check if the user's role is included in the specified roles array
            if (!roles.includes(user.role)) {
                return res.status(403).json({ message: "Access denied. You do not have permission to perform this action." });
            }

            // If user role matches, proceed to the next middleware
            next();

        } catch (err) {
            return res.status(401).json({ message: "Unauthorized." });
        }
    }
};

// Example use in a route (Note: This is not part of the middleware, just an example of usage)
/*
const express = require('express');
const app = express();
const { checkUserRole } = require('./middleware/checkUserRole');

app.get('/admin', checkUserRole(['Admin']), (req, res) => {
    res.send('Welcome Admin.');
});
*/


User: Task Name: "Create Router for Project Controller" 
			Description: "Generate a router for handling requests to the project controller."
			Requirements:
			1. Database: 
			2. Output needed: Generate router code. Add necessary request parameters to the routes.
	       
			3. Tasks to implement: Create a router module for managing project-related endpoints., 
Ensure the router includes necessary routes for all project controller functions., 
Add parameters to routes if needed based on controller method requirements., 
Export the router to be used in the main application server.
	
			4. Supporting data 
const mongoose = require('mongoose');
const Project = require('../models/Project');  // Assuming the Project schema is in models/Project.js

exports.createProject = async (req, res) => {
    try {
        const { title, description, deadline, teamMembers } = req.body;

        // Check if all required fields are provided
        if (!title || !description || !deadline || !teamMembers || !Array.isArray(teamMembers)) {
            return res.status(400).json({ error: 'Please provide all required fields: title, description, deadline, and teamMembers.' });
        }

        // Create the project object
        const project = new Project({
            title: title,
            description: description,
            deadline: new Date(deadline),
            teamMembers: teamMembers,
            projectManager: req.user._id  // Assuming the user ID is available in req.user
        });

        // Save the project to the database
        await project.save();

        // Respond with success message containing project details
        res.status(201).json({
            message: 'Project created successfully!',
            project: {
                id: project._id,
                title: project.title,
                description: project.description,
                deadline: project.deadline,
                teamMembers: project.teamMembers,
                projectManager: project.projectManager
            }
        });
    } catch (error) {
        // Handle errors like missing fields, invalid parameters, or database issues
        res.status(500).json({ error: 'An error occurred while creating the project. Please try again.' });
    }
};

exports.readProjectsByUserRole = async (userId) => {
    try {
        // Fetch all projects where the user is part of the project
        const projects = await Project.find({ 'participants': userId }).exec();

        // Return filtered projects
        return projects;

    } catch (error) {
        console.error("Error retrieving projects:", error);
        throw new Error('Could not retrieve projects');
    }
}

// Function to update a project with specified fields.
exports.updateProject = async (req, res) => {
  try {
    // Destructure the request body to get the required fields
    const { projectId, title, description, deadline, teamMembers } = req.body;

    // Validate that required fields are provided
    if (!projectId || !title || !deadline || !teamMembers || teamMembers.length === 0) {
      return res.status(400).json({ error: 'Project ID, title, deadline, and at least one team member are required.' });
    }

    // Find the project by ID and update it with the new data
    const updatedProject = await Project.findByIdAndUpdate(
      projectId, 
      {
        title, 
        description, 
        deadline, 
        teamMembers
      },
      { new: true } // This option returns the updated document
    );

    // If the project is not found, send an error response
    if (!updatedProject) {
      return res.status(404).json({ error: 'Project not found' });
    }

    // Respond with the success message and updated project details
    res.status(200).json({
      message: 'Project updated successfully',
      project: updatedProject
    });

  } catch (error) {
    // Handle any potential errors such as database issues
    res.status(500).json({ error: 'An error occurred while updating the project' });
  }
};

// Define and export the projectController function to handle deleting a project by its ID
exports.deleteProject = async (req, res) => {
    try {
        // Extract the project ID from the request parameters
        const projectId = req.params.id;

        // Attempt to find and delete the project in the database
        const deletedProject = await Project.findOneAndDelete({ _id: projectId });

        // If no project is found, return a 404 response
        if (!deletedProject) {
            return res.status(404).json({ message: 'Project not found' });
        }

        // Return a success response if the project was successfully deleted
        res.status(200).json({ message: 'Project deleted successfully' });
    } catch (error) {
        // If an error occurs, log it and return a 500 response
        console.error('Error deleting project:', error);
        res.status(500).json({ message: 'An error occurred while trying to delete the project' });
    }
};

// Ensure to make `isImport` false for the respective logic

			
		Please generate the code for above tasks, following the instructions and including comments for clarity and logic for Dependencies must needed.
	
		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.
Assistant: