User: Task: "Create Login Api for User"
    Description: "Generate a Node.js Login Api with with given dependenceis"
    Requirements:
    - Database: mongoose
    - Authentication: None specified
    - Output needed: Return only the function code as specified in dependencies
    - Dependencies: Create login api function as exported function it's self. function mode :-  exports.functionname = async () =>{...} , 
Accept two parmas request and response, 
Accept two creidentional from User one email and passowrd, 
User cridentional should validated by joi, , 
Api should build inder try catch method for error handeling., 
For compare passwords use bacrypt lirbary, , 
Data should be saved in User database., 
Use redis caching to store logged users. Storing key `logUser`, 
Response should send back in Json formate with 'status' code of 200
    - Previous Code 
// dependencies
const bcrypt = require('bcrypt');
const Joi = require('joi');
const mongoose = require('mongoose');

const User = require('../models/User.js');

exports.registerUser = async (request, response) => {
    // Define validation schema using Joi
    const schema = Joi.object({
        email: Joi.string().email().required(),
        password: Joi.string().min(6).required()
    });

    try {
        // Validate request body against the schema
        const { error } = schema.validate(request.body);
        if (error) {
            return response.status(400).json({ status: 400, message: error.details[0].message });
        }

        const { email, password } = request.body;

        // Check if user already exists
        const existingUser = await User.findOne({ email });
        if (existingUser) {
            return response.status(400).json({ status: 400, message: 'User already exists' });
        }

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

        // Create new user
        const newUser = new User({
            email,
            password: hashedPassword
        });

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

        // Send success response
        response.status(200).json({ status: 200, message: 'User registered successfully' });
    } catch (err) {
        // Handle errors
        response.status(500).json({ status: 500, message: 'Internal Server Error' });
    }
};

const User = require('../models/User.js');
const client = redis.createClient();

exports.loginUser = async (request, response) => {
    // Define validation schema using Joi
    const schema = Joi.object({
        email: Joi.string().email().required(),
        password: Joi.string().min(6).required()
    });

    try {
        // Validate request body against the schema
        const { error } = schema.validate(request.body);
        if (error) {
            return response.status(400).json({ status: 400, message: error.details[0].message });
        }

        const { email, password } = request.body;

        // Check if user exists
        const existingUser = await User.findOne({ email });
        if (!existingUser) {
            return response.status(400).json({ status: 400, message: 'Invalid email or password' });
        }

        // Compare passwords
        const isMatch = await bcrypt.compare(password, existingUser.password);
        if (!isMatch) {
            return response.status(400).json({ status: 400, message: 'Invalid email or password' });
        }
        
        // Store logged user in redis
        client.setex('logUser', 3600, JSON.stringify({ email }));

        // Send success response
        response.status(200).json({ status: 200, message: 'Login successful' });
    } catch (err) {
        // Handle errors
        response.status(500).json({ status: 500, message: 'Internal Server Error' });
    }
};

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