From 7bbf62f28a4ab37053546bd04a4a656e6d600ac5 Mon Sep 17 00:00:00 2001 From: Janishar Ali Date: Thu, 2 Apr 2020 17:09:46 +0530 Subject: [PATCH] add code suger in profile --- src/routes/v1/profile/user.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/v1/profile/user.ts b/src/routes/v1/profile/user.ts index ac6c775..9caaa8d 100644 --- a/src/routes/v1/profile/user.ts +++ b/src/routes/v1/profile/user.ts @@ -15,7 +15,7 @@ const router = express.Router(); router.get('/public/id/:id', validator(schema.userId, ValidationSource.PARAM), asyncHandler(async (req: ProtectedRequest, res, next) => { const user = await UserRepo.findPublicProfileById(new Types.ObjectId(req.params.id)); - if (user == null) throw new BadRequestError('User not registered'); + if (!user) throw new BadRequestError('User not registered'); return new SuccessResponse('success', _.pick(user, ['name', 'profilePicUrl'])).send(res); })); @@ -27,14 +27,14 @@ router.use('/', authentication); router.get('/my', asyncHandler(async (req: ProtectedRequest, res, next) => { const user = await UserRepo.findProfileById(req.user._id); - if (user == null) throw new BadRequestError('User not registered'); + if (!user) throw new BadRequestError('User not registered'); return new SuccessResponse('success', _.pick(user, ['name', 'profilePicUrl', 'roles'])).send(res); })); router.put('/', validator(schema.profile), asyncHandler(async (req: ProtectedRequest, res, next) => { const user = await UserRepo.findProfileById(req.user._id); - if (user == null) throw new BadRequestError('User not registered'); + if (!user) throw new BadRequestError('User not registered'); if (req.body.name) user.name = req.body.name; if (req.body.profilePicUrl) user.profilePicUrl = req.body.profilePicUrl;