const {asyncHandler} = require("../middleware/errorHandler")
const ApiResponse = require("../utils/apiResponse")
const otpService = require("../services/otpService")

exports.generateOTP = asyncHandler( async(req , res) => {
    const ip = req.ip || req.connection.remoteAddress;
    const {type} = req.body;
     const device = req.headers['user-agent'];
    const result = await otpService.generateOTP(req.user.id ,type, ip, device)
    ApiResponse.success(res, result, "Otp has been sent")
})
