Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async findUserById(userId: number, loggedUserId: number): Promise<UserDTO> {
- const foundUser: User = await this.usersRepository
- .findOne({ where: { id: userId, isDeleted: false }, relations: ['followers'] });
- if (!foundUser) {
- throw new NotFoundUserError();
- }
- const isFollowed: boolean = loggedUserId !== -1 &&
- foundUser['followers'].some((u: User) => u.id === loggedUserId);
- return {
- ...this.mapper.toUserDTO({ ...foundUser }),
- isFollowed,
- };
- }
Add Comment
Please, Sign In to add comment