From 2ad6018806886c92854baf2f1327a642eba556bf Mon Sep 17 00:00:00 2001 From: CookieDasora Date: Sun, 1 Oct 2023 14:46:14 -0300 Subject: [PATCH] feat: updated fetch-info updated fetch-info to return user's followers and following --- src/services/users/fetch-info.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/services/users/fetch-info.ts b/src/services/users/fetch-info.ts index b16c686..fb62477 100644 --- a/src/services/users/fetch-info.ts +++ b/src/services/users/fetch-info.ts @@ -8,10 +8,13 @@ async function userFetchInfoService( username, }, select: { + id: true, profileImage: true, displayName: true, username: true, createdAt: true, + followers: true, + following: true, posts: { select: { id: true, @@ -32,7 +35,16 @@ async function userFetchInfoService( return new Error('User not found') } - return user + const followers = user.followers.length + const following = user.following.length + + const info = { + ...user, + followers, + following, + } + + return info } export default userFetchInfoService