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/authController.js` and assign it to `taskCntl`, 
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', taskCntl.apiName) `, 
Read each API name from the supporting data and dynamically create a route for each, 
For deleteTask 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 
















const express = require('express');
const taskCntl = require('../controllers/authController.js');
const router = express.Router();
// Assuming the supporting data APIs are 'registerUser', 'loginUser', and 'deleteTask'

router.post('/registerUser', taskCntl.registerUser);
router.post('/loginUser', taskCntl.loginUser);


module.exports = router;

    - Supporting data 
const bcrypt = require('bcrypt');
const Joi = require('joi');
const mongoose = require('mongoose');
const User = require('../models/User.js'); // Import User schema

// Define Register API function
exports.registerUser = async (req, res) => {
    try {
        // Validate request data using Joi
        const schema = Joi.object({
            email: Joi.string().email().required(),
            password: Joi.string().min(6).required()
        });

        const { error } = schema.validate(req.body);
        if (error) {
            return res.status(400).json({ error: error.details[0].message });
        }

        // Destructure email and password from request body
        const { email, password } = req.body;

        // Hash the password using bcrypt
        const salt = await bcrypt.genSalt(10);
        const hashedPassword = await bcrypt.hash(password, salt);

        // Create a new User instance
        const user = new User({
            email,
            password: hashedPassword
            // Other fields from User schema should be added here if necessary
        });

        // Save the user data to the database
        await user.save();

        // Send response back with status code 200
        res.status(200).json({ status: "User registered successfully" });
    } catch (err) {
        // Handle errors
        res.status(500).json({ error: "An error occurred during registration" });
    }
};






exports.loginUser = async (req, res) => {
    try {
        // Validate request data using Joi
        const schema = Joi.object({
            email: Joi.string().email().required(),
            password: Joi.string().min(6).required()
        });

        const { error } = schema.validate(req.body);
        if (error) {
            return res.status(400).json({ error: error.details[0].message });
        }

        // Destructure email and password from request body
        const { email, password } = req.body;

        // Find the user in the database
        const user = await User.findOne({ email });
        if (!user) {
            return res.status(400).json({ error: "Invalid email or password" });
        }

        // Compare the provided password with the stored password
        const validPassword = await bcrypt.compare(password, user.password);
        if (!validPassword) {
            return res.status(400).json({ error: "Invalid email or password" });
        }

        // Store logged user in Redis Cache
        client.set("logUser", JSON.stringify(user), (err, reply) => {
            if (err) throw err;
            // Optionally handle redis logging reply like so
            console.log(reply);
        });

        // Send response back with status code 200
        res.status(200).json({ status: "User logged in successfully" });
    } catch (err) {
        // Handle errors
        res.status(500).json({ error: "An error occurred during login" });
    }
};

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