Skip to content

Conversation

@laxman-aqw
Copy link
Collaborator

@laxman-aqw laxman-aqw commented Oct 15, 2025

  • Added middleware to limit request per IP.
  • updated the HTTP status for endpoints

@laxman-aqw laxman-aqw self-assigned this Oct 15, 2025
@laxman-aqw laxman-aqw added the enhancement New feature or request label Oct 15, 2025
@laxman-aqw laxman-aqw changed the base branch from feat-guards to fix-migration October 15, 2025 06:42
@laxman-aqw laxman-aqw changed the title Add: added limit throttler in endpoints Add: added middleware to limit request per IP Oct 15, 2025
@HttpCode(HttpStatus.ACCEPTED)
@Post('resend-verification')
async reSendVerification(@Body('email') email: string) {
if (!email) throw new BadRequestException('Email is required');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dont do this in controller , business logics should be in service , you can add validation by creating a dto I guess?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@HttpCode(HttpStatus.OK)
@Get('verify-email')
async verifyEmail(@Query('token') token: string) {
if (!token) throw new BadRequestException('Token is required');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated here too!


const ipMap = new Map<string, RateLimitInfo>();

@Injectable()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Nest throttler might be useful

throw new BadRequestException({
message: 'Something went wrong during signup',
error: (error as Error)?.message,
message: (error as Error)?.message,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: I don't think this might be a good approach . Error can be of different types. Even if it is query failed error or some errors that are coming from server it will throw BadReqauestException. Also in line 140 , that may be a Not Found Exception Error

Suggested change
message: (error as Error)?.message,
In line 140
const user = await this.userRepository.findOne({
where: {
email: payload.email,
},
});
if (!user) throw newNotFoundException('User not found');

Better do not use try catch until its an external service we are using , but if you have to handle error properly .

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ve already removed the try-catch blocks in the previous branch, so this will be resolved once that branch is merged.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated!

Copy link

@pratham-outside pratham-outside left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment added

@laxman-aqw laxman-aqw changed the base branch from fix-migration to develop November 6, 2025 07:40
@laxman-aqw laxman-aqw changed the base branch from develop to fix-migration November 6, 2025 08:27
@laxman-aqw laxman-aqw merged commit 255f3dd into fix-migration Nov 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Development

Successfully merging this pull request may close these issues.

3 participants