I am implementing JWT in NestJS + Angular but I am not sure if I am doing it correctly.
Here is my endpoint:
@Post('sign-up')
async signUp(
@Body() data: SignUpModelInterface,
@Res({ passthrough: true }) response: Response
): Promise<void> {
const token: string = await this.authService.signUp(data);
response.cookie('access-token', token, { httpOnly: true });
}
Is that the correct way to create a new user and set the access token in the response? You can also see that I am not returning any value from the endpoint (i.e., Promise<void>) but again I am not sure if it is the correct manner.
I'd suggest returning something even just a simple { success: true } or similar, to make it easier to say that it ended, even just a return statement, to make the flow of code more apparent, but this would be fine for setting the access-token cookie as an HttpOnly cookie