Files
digifiMicro-Loan/controller/userController.js
T
CHIEFSOFT\ameye 2692a07db8 first commit
2024-05-06 10:14:26 -04:00

27 lines
724 B
JavaScript

import User from "../model/userModel.js";
export const create = async (req,res)=>{
try {
const userData = new User(req.body);
const { email } = userData;
const userExist = await User.findOne({email});
if (userExist) {
return res.status(400).json({message: "User already exixt"});
}
const saveUser = await userData.save();
res.status(200).json(saveUser);
} catch (error) {
res.status(500).json({error: `Internal Server error 002 ${error} ` });
}
}
export const fetch = async (req, res)=>{
try{
return res.json("Hello Worlds");
}catch(error){
res.status(500).json({error: "Internal Server error"});
}
}