feat(backend): add follow/unfollow endpoints and live follower counts

This commit is contained in:
admin committed 2025-12-25 13:12:56 +01:00
1 parent 0778f188bc
commit 27174bef18
2 files changed
+33 -3

No files matched your search

+10 -3
View File
@@ -28,10 +28,17 @@ export class PostsService {
},
},
author: {
select: {
name: true,
},
select: {
name: true,
_count: {
select: {
followers: true,
following: true,
},
},
},
},
} as const;
// Sichtbarkeit
+23
View File
@@ -0,0 +1,23 @@
async getUserProfile(userId: number) {
const [user, followersCount, followingCount] = await Promise.all([
this.prisma.user.findUnique({
where: { id: userId },
select: {
id: true,
name: true,
},
}),
this.prisma.follow.count({
where: { followingId: userId },
}),
this.prisma.follow.count({
where: { followerId: userId },
}),
]);
return {
...user,
followersCount,
followingCount,
};
}