-
Notifications
You must be signed in to change notification settings - Fork 18
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
separated checking for solana and etherium users #1876
Conversation
WalkthroughThe changes introduce a comprehensive suite of tests for project-related functionalities in Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Warning Rate limit exceeded@kkatusic has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 17 minutes and 16 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 5
🧹 Outside diff range and nitpick comments (4)
src/resolvers/projectResolver.ts (2)
1639-1648
: LGTM: Email verification check properly implemented, but consider refactoringThe email verification check is well-implemented, but this pattern is repeated across multiple mutations. Consider extracting this into a reusable middleware or decorator.
Example implementation:
const requireVerifiedEmail = async (userId: number): Promise<void> => { const user = await findUserById(userId); if (!user) { throw new Error(i18n.__(translationErrorMessagesKeys.USER_NOT_FOUND)); } if (!user.isEmailVerified) { throw new Error(i18n.__(translationErrorMessagesKeys.EMAIL_NOT_VERIFIED)); } };
Line range hint
1579-1690
: Consider implementing a declarative approach for email verificationWhile the email verification checks are well-implemented, the current approach leads to code duplication. Consider one of these architectural improvements:
- TypeGraphQL decorator:
function RequireVerifiedEmail() { return createMethodDecorator(async ({ context }, next) => { const { user } = context.req; await requireVerifiedEmail(user.userId); return next(); }); }
- GraphQL middleware:
const emailVerificationMiddleware = async ( resolve: any, root: any, args: any, context: any, info: any ) => { const { user } = context.req; await requireVerifiedEmail(user.userId); return resolve(root, args, context, info); };This would make the code more maintainable and reduce duplication while keeping the same security checks.
src/resolvers/projectResolver.test.ts (2)
5532-5533
: UsesaveUserDirectlyToDb
helper function for user creationIn this test case, you're manually creating a
User
instance and saving it directly to the database. To ensure consistency and maintainability across tests, consider using thesaveUserDirectlyToDb
helper function, which handles default properties and setups required for a user.Apply this diff to refactor:
- const user = await User.create({ - walletAddress: generateRandomEtheriumAddress(), - loginType: 'wallet', - firstName: 'testEditProjectUpdateFateme', isEmailVerified: true, - }).save(); + const user = await saveUserDirectlyToDb(generateRandomEtheriumAddress());
5648-5649
: UsesaveUserDirectlyToDb
helper function for user creationSimilarly, in this test, you're manually creating a
User
object. It's recommended to use thesaveUserDirectlyToDb
helper function for consistency and to handle any default user properties.Apply this diff to refactor:
- const user = await User.create({ - walletAddress: generateRandomEtheriumAddress(), - loginType: 'wallet', - firstName: 'testDeleteProjectUpdateFateme', isEmailVerified: true, - }).save(); + const user = await saveUserDirectlyToDb(generateRandomEtheriumAddress());
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
src/resolvers/projectResolver.test.ts
(2 hunks)src/resolvers/projectResolver.ts
(3 hunks)src/resolvers/userResolver.ts
(3 hunks)
🔇 Additional comments (2)
src/resolvers/projectResolver.ts (1)
1579-1583
: LGTM: Email verification check properly implemented
The email verification check is well-placed before any project operations and uses proper error handling with internationalized messages.
src/resolvers/userResolver.ts (1)
35-35
: Importing isSolanaAddress
Function
The addition of isSolanaAddress
import is necessary for the new Solana address checks and is correctly implemented.
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.
LGTM!
Summary by CodeRabbit
New Features
Bug Fixes
Tests