-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement getUserProfile grpc #23
Conversation
src/proto/user.proto
Outdated
string access_token = 1; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we use user_id instead of access_token since we already have it on gateway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it
src/user/user.service.ts
Outdated
public async getUserProfile(request: GetUserProfileRequest): Promise<GetUserProfileResponse> { | ||
try { | ||
|
||
let credential = this.jwtService.decode( | ||
request.accessToken, | ||
) as JwtPayload; | ||
let userId = credential.sub; | ||
let user = await this.userRepo.findUserById(userId); | ||
let userSportArea = await this.sportAreaListRepo.findSportAreaOfUser(userId) | ||
return { | ||
id: user.id, | ||
firstName: user.firstName, | ||
lastName: user.lastName, | ||
email: user.email, | ||
photoURL: user.photoURL, | ||
role: user.role, | ||
sportAreaId: ((userSportArea == null) ? null : userSportArea.SportAreaId), | ||
} | ||
|
||
} catch (err: any) { | ||
console.log(err); | ||
if (!(err instanceof RpcException)) { | ||
throw new RpcException({ | ||
code: status.INTERNAL, | ||
message: 'internal server error cant get user profile', | ||
}); | ||
} | ||
throw err; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to call fileService to retrieve profileUrl
6dc8a0d
to
761a298
Compare
This is how to invoke a gRPC method to getUserProfile
This is gRPC request/response look like