Spaces:
Paused
Paused
Download controllers/profileController.js from arabdullah/chatty: direct link, hf CLI and curl.
- Browser
- Download file 911 Bytes
-
https://huggingface.co/spaces/arabdullah/chatty/resolve/main/controllers/profileController.js
- Command line
-
hf download hf://spaces/arabdullah/chatty/controllers/profileController.js
-
curl -L -o profileController.js https://huggingface.co/spaces/arabdullah/chatty/resolve/main/controllers/profileController.js
911 Bytes
| const catchAsyncError = require("../utilities/catchAsyncError"); | |
| const ReqError = require("../utilities/ReqError"); | |
| const User = require("../models/User"); | |
| exports.getSelfProfile = catchAsyncError(async (req, res, next) => { | |
| const user = await User.findById(req.cookies.userId).select( | |
| "-contacts -password -__v" | |
| ); | |
| if (!user) return next(new ReqError(400, "User does not exist")); | |
| res.status(200).json({ | |
| status: "Success", | |
| data: { | |
| user, | |
| }, | |
| }); | |
| }); | |
| exports.updateSelfProfile = catchAsyncError(async (req, res, next) => { | |
| // This action should send a message to all sockets to update username if user changes username | |
| const user = await User.findByIdAndUpdate(req.cookies.userId, req.body, { | |
| new: true, | |
| }); | |
| if (!user) return next(new ReqError(400, "User does not exist")); | |
| res.status(200).json({ | |
| status: "Success", | |
| data: { | |
| user, | |
| }, | |
| }); | |
| }); | |