-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a daily limit for project creation, capping the number of new projects a user can create per day. - Added a new query endpoint that lets users check how many projects they can still create today. - Enhanced error notifications to clearly inform users when their daily project creation limit has been reached. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information
1 parent
7136304
commit b616285
Showing
3 changed files
with
98 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { ForbiddenException, HttpStatus } from '@nestjs/common'; | ||
import { GraphQLError } from 'graphql'; | ||
|
||
export const PROJECT_DAILY_LIMIT = 3; // Maximum number of projects a user can create per day | ||
|
||
export enum ProjectErrorCode { | ||
DAILY_LIMIT_EXCEEDED = 'DAILY_LIMIT_EXCEEDED', | ||
} | ||
|
||
export class ProjectRateLimitException extends ForbiddenException { | ||
constructor(limit: number) { | ||
super( | ||
`Daily project creation limit of ${limit} reached. Please try again tomorrow.`, | ||
); | ||
} | ||
|
||
getGraphQLError(): GraphQLError { | ||
return new GraphQLError(this.message, { | ||
extensions: { | ||
code: ProjectErrorCode.DAILY_LIMIT_EXCEEDED, | ||
limit: PROJECT_DAILY_LIMIT, | ||
status: HttpStatus.TOO_MANY_REQUESTS, | ||
}, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters