MCPcopy Create free account
hub / github.com/Jenifer2833/fullstack-chat-app / updateProfile

Function updateProfile

backend/src/controllers/auth.controller.js:89–106  ·  view source on GitHub ↗
(req,res)

Source from the content-addressed store, hash-verified

87};
88
89export const updateProfile= async(req,res)=>{
90 try{
91 const {profilePic}=req.body;
92 const userId=req.user._id;
93
94 if(!profilePic){
95 return res.status(400).json({message:"Profile pic is required"});
96 }
97
98 const uploadResponse= await cloudinary.uploader.upload(profilePic);
99 const updatedUser = await User.findByIdAndUpdate(userId,{profilePic:uploadResponse.secure_url},{new:true});
100
101 res.status(200).json(updatedUser);
102 }catch(error){
103 console.log("error in update profile:",error);
104 res.status(500).json({message:"Internal Server Error"});
105 }
106};
107
108export const checkAuth=(req,res)=>{
109 try{

Callers 1

handleImageUploadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected