Skip to content

Commit aeb846b

Browse files
committed
get profile service dynamic by user id
1 parent 5babff7 commit aeb846b

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

src/app/modules/user/user.controller.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ const createUser = catchAsync(async (req: Request, res: Response) => {
1818
});
1919

2020
const getUserProfile = catchAsync(async (req: Request, res: Response) => {
21-
const user = req.user;
22-
const result = await UserService.getUserProfileFromDB(user);
21+
const result = await UserService.getSingleUserFromDB(req.user.id);
2322

2423
sendResponse(res, {
2524
success: true,

src/app/modules/user/user.service.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ const createUserToDB = async (payload: Partial<IUser>): Promise<IUser> => {
4040
return createUser;
4141
};
4242

43-
const getUserProfileFromDB = async (
44-
user: JwtPayload
45-
): Promise<Partial<IUser>> => {
46-
const { id } = user;
43+
const getSingleUserFromDB = async (id: string): Promise<Partial<IUser>> => {
4744
const isExistUser = await User.isExistUserById(id);
4845
if (!isExistUser) {
4946
throw new ApiError(StatusCodes.BAD_REQUEST, "User doesn't exist!");
@@ -76,6 +73,6 @@ const updateProfileToDB = async (
7673

7774
export const UserService = {
7875
createUserToDB,
79-
getUserProfileFromDB,
76+
getSingleUserFromDB,
8077
updateProfileToDB,
8178
};

0 commit comments

Comments
 (0)