Skip to content
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

Feat/collabsection #94

Merged
merged 12 commits into from
Dec 2, 2024
Merged

Conversation

ayushhunt
Copy link
Contributor

@ayushhunt ayushhunt commented Dec 1, 2024

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a new ContributorsGrid component to the About page, displaying contributor information dynamically.
    • Added an API endpoint for fetching contributor data.
    • Implemented a scheduled task to publish contributor data from a GitHub repository.
  • Improvements

    • Enhanced the About page layout with contributor details.
    • Updated configuration to allow images from GitHub avatars.
  • Bug Fixes

    • Removed unnecessary ESLint and TypeScript settings from configuration files.
  • Chores

    • Updated dependency versions for improved performance and stability.

Copy link

vercel bot commented Dec 1, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
plura-status ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 2, 2024 3:28pm
plura-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 2, 2024 3:28pm

Copy link

coderabbitai bot commented Dec 1, 2024

Walkthrough

The pull request includes updates to dependency versions in the package.json files for both the triggers and www applications, changing specific dependencies to fixed versions. Additionally, new components and API endpoints are introduced, enhancing the functionality of the application. The About page is modified to include a dynamic contributor grid, while a scheduled task for fetching contributor data is added. Configuration files are also adjusted, primarily focusing on the removal of certain settings and the addition of properties to manage image domains.

Changes

File Path Change Summary
apps/triggers/package.json Updated @trigger.dev/sdk from ^3.1.2 to 3.3.1 and @trigger.dev/build from ^3.1.2 to 3.3.1.
apps/www/app/(routes)/about/page.tsx Added ContributorsGrid import, new state variable contributors, and a useEffect for fetching data.
apps/www/layout.tsx Removed PosthogProvider from RootLayout.
apps/www/next.config.ts Added images property with domains: ['avatars.githubusercontent.com'].
apps/www/package.json Updated @radix-ui/react-tooltip from ^1.1.3 to ^1.1.4 and added @repo/cache dependency.
packages/crypt/tsconfig.tsbuildinfo New TypeScript build information file added.
packages/crypt/.gitignore Added tsconfig.tsbuildinfo to .gitignore.
apps/api/app/api/[[...route]]/contributors.ts New API endpoint defined to fetch contributor data.
apps/api/app/api/[[...route]]/route.ts Added cors middleware and new route for /contributors.
apps/api/next.config.js Removed ESLint and TypeScript settings from configuration.
apps/triggers/src/contributors.ts Introduced publishContributorsTask for scheduled data fetching from GitHub.
apps/www/components/custom/contributors-grid.tsx New ContributorsGrid component created to display contributor information.

Possibly related PRs

  • route error fix #18: The changes in this PR involve modifications to the route.ts file, which is related to the API structure and routing, similar to the changes in the contributors.ts file in the main PR that also deals with API functionality.
  • add mail service #23: This PR includes updates to the package.json file, which is relevant as the main PR also modifies the package.json to update dependency versions.
  • fix error and lint #37: This PR focuses on fixing errors and linting, which may relate to the overall quality and structure of the code, including the package.json file changes in the main PR.

Suggested labels

enhancement

🐰 In the meadow, hopping with glee,
New contributors come, as bright as can be!
With grids and tasks, our code's now a treat,
Fetching their data, oh what a feat!
So let’s celebrate, with joy we will sing,
For every new change, fresh wonders they bring! 🌼✨

Warning

Rate limit exceeded

@ayushhunt has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 8 minutes and 44 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between 844a04f and 824e749.


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

vercel bot commented Dec 1, 2024

@ayushhunt is attempting to deploy a commit to the BlueFinZ Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

gitguardian bot commented Dec 1, 2024

⚠️ GitGuardian has uncovered 2 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

Since your pull request originates from a forked repository, GitGuardian is not able to associate the secrets uncovered with secret incidents on your GitGuardian dashboard.
Skipping this check run and merging your pull request will create secret incidents on your GitGuardian dashboard.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
- - Generic High Entropy Secret e886863 packages/cache/src/index.ts View secret
- - Generic High Entropy Secret b6be48d packages/cache/src/index.ts View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 11

🧹 Outside diff range and nitpick comments (5)
apps/www/components/custom/ColloboratorGridWrapper.tsx (1)

15-15: Add loading state handling.

The async component should handle loading states to improve user experience.

-  return <ContributorsGrid data={contributors} />;
+  if (contributors.length === 0) {
+    return <div>Loading contributors...</div>;
+  }
+  return <ContributorsGrid data={contributors} />;
apps/www/package.json (1)

⚠️ Multiple packages using experimental React version

The verification confirms that the experimental React release candidate 19.0.0-rc-02c0e824-20241028 is being used across multiple packages in the monorepo:

  • apps/www/package.json
  • apps/api/package.json
  • apps/app/package.json
  • packages/mail/package.json

This widespread use of an experimental version increases the risk of instability across the entire application. Consider upgrading all packages to the latest stable version of React (19.0.0) unless there's a documented requirement for specific RC features.

🔗 Analysis chain

Line range hint 47-48: Review usage of experimental React version

The project is using an experimental React release candidate (19.0.0-rc-02c0e824-20241028). This could introduce instability in production.

Consider using the latest stable version of React unless there's a specific need for the release candidate features.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if this experimental version is used across the monorepo
fd package.json | xargs rg "19.0.0-rc-02c0e824-20241028"

Length of output: 539

apps/www/app/layout.tsx (1)

PosthogProvider removal requires attention - analytics still in use

The removal of PosthogProvider from the layout is concerning as Posthog analytics is still actively used in the codebase:

  • apps/www/hooks/posthog.tsx contains active Posthog configuration and provider
  • apps/www/app/layout.tsx imports the PosthogProvider
  • Similar setup exists in the apps/app directory

The removal of the provider while keeping the imports and configuration will break analytics functionality. Either:

  1. Restore the PosthogProvider in the layout
  2. Or properly remove all Posthog-related code if analytics are no longer needed
🔗 Analysis chain

Line range hint 20-36: Verify impact of PosthogProvider removal

The PosthogProvider has been removed from the layout. This could affect analytics tracking across the application, including the new contributor section.

If analytics are still needed:

  1. Document why PosthogProvider was removed
  2. Ensure there's an alternative analytics solution in place
  3. Update any components that depend on Posthog context
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any remaining Posthog usage that might break
rg -l "posthog" --type ts --type tsx

Length of output: 64


Script:

#!/bin/bash
# Check for any remaining Posthog usage with correct file extensions
rg -l "posthog" -g "*.ts" -g "*.tsx"

# Also check for any Posthog-related imports or configurations
rg "posthog" -g "*.ts" -g "*.tsx" -g "*.js" -g "*.jsx" -A 2

Length of output: 1852

apps/www/app/api/getDummyData.ts (1)

4-7: Consider enhancing the DummyData type

The current type might be too simplistic for contributor data.

Consider expanding it to include more relevant fields:

type DummyData = {
  timestamp: string;
  message: string;
  id: string;
  type: 'info' | 'warning' | 'error';
  metadata?: Record<string, unknown>;
};
apps/www/components/custom/Colloborators.tsx (1)

42-49: Improve accessibility of contributor links

The contributor links could benefit from better accessibility attributes.

   <a
     href={contributor.html_url}
     target="_blank"
     rel="noopener noreferrer"
-    className="text-sm font-medium text-gray-300 hover:text-blue-400"
+    className="text-sm font-medium text-gray-300 hover:text-blue-400 focus:outline-none focus:ring-2 focus:ring-blue-500"
+    aria-label={`Visit ${contributor.login}'s GitHub profile`}
   >
     {contributor.login}
   </a>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 8366f83 and 194e07e.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (11)
  • apps/triggers/package.json (1 hunks)
  • apps/triggers/src/collaborator.status.ts (1 hunks)
  • apps/triggers/trigger.config.ts (1 hunks)
  • apps/www/app/(routes)/about/page.tsx (2 hunks)
  • apps/www/app/api/getDummyData.ts (1 hunks)
  • apps/www/app/layout.tsx (2 hunks)
  • apps/www/components/custom/ColloboratorGridWrapper.tsx (1 hunks)
  • apps/www/components/custom/Colloborators.tsx (1 hunks)
  • apps/www/next.config.ts (1 hunks)
  • apps/www/package.json (1 hunks)
  • packages/crypt/tsconfig.tsbuildinfo (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • apps/triggers/trigger.config.ts
  • packages/crypt/tsconfig.tsbuildinfo
🧰 Additional context used
🪛 eslint
apps/www/app/(routes)/about/page.tsx

[error] 3-3: 'ContributorsGrid' is defined but never used.

(@typescript-eslint/no-unused-vars)


[error] 4-4: 'DummyDataPage' is defined but never used.

(@typescript-eslint/no-unused-vars)

🪛 Biome (1.9.4)
apps/triggers/src/collaborator.status.ts

[error] 41-41: Unexpected constant condition.

(lint/correctness/noConstantCondition)

🔇 Additional comments (5)
apps/www/next.config.ts (1)

10-12: LGTM! Configuration correctly allows GitHub avatar images.

The addition of 'avatars.githubusercontent.com' to the allowed domains is necessary for displaying GitHub contributor avatars.

Let's verify no other GitHub-related domains are needed:

✅ Verification successful

Configuration for GitHub avatar images is complete and sufficient

The verification confirms that 'avatars.githubusercontent.com' is the only GitHub-related domain referenced in the codebase, and it's properly configured in the Next.js config. No other GitHub image domains are being used that would require additional configuration.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if any other GitHub image domains are referenced in the codebase
rg -g '*.{tsx,ts,js,jsx}' 'githubusercontent\.com' | grep -v 'avatars.githubusercontent.com'

Length of output: 92


Script:

#!/bin/bash
# Let's search for any image URLs or references to githubusercontent.com in the codebase
# Using a broader search pattern and including more context
rg -i -g '*.{tsx,ts,js,jsx,md}' -B 2 -A 2 'githubusercontent\.com'

# Also search for any Next.js image components or img tags that might use GitHub URLs
ast-grep --pattern 'Image src={$_}'
ast-grep --pattern 'img src={$_}'
ast-grep --pattern 'img src="$_"'

Length of output: 393

apps/triggers/package.json (1)

15-15: Verify trigger.dev version compatibility and security.

The change pins the versions to exactly 3.3.1, removing the flexibility of the caret (^) operator. While this provides better reproducibility, it requires manual updates for security patches.

Let's verify the version choice:

Also applies to: 18-18

✅ Verification successful

Version 3.3.1 is current and secure

The version pinning to 3.3.1 is appropriate as:

  • It matches the latest published version on npm for both @trigger.dev/sdk and @trigger.dev/build
  • No security vulnerabilities were found for this package
  • Version pinning provides better reproducibility for production deployments
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check latest versions and changelogs
echo "Checking @trigger.dev/sdk versions..."
curl -s https://registry.npmjs.org/@trigger.dev/sdk | jq -r '.["dist-tags"].latest'

echo "Checking @trigger.dev/build versions..."
curl -s https://registry.npmjs.org/@trigger.dev/build | jq -r '.["dist-tags"].latest'

# Check for any security advisories
echo "Checking for security advisories..."
gh api graphql -f query='
{
  securityVulnerabilities(first: 5, ecosystem: NPM, package: "@trigger.dev/sdk") {
    nodes {
      advisory {
        summary
        severity
        publishedAt
      }
      vulnerableVersionRange
    }
  }
}'

Length of output: 735

apps/www/components/custom/ColloboratorGridWrapper.tsx (1)

2-2: Verify ContributorsGrid component implementation.

Let's verify the imported component exists and implements proper type checking.

✅ Verification successful

Let me try a different approach to verify the component's existence and implementation.


Let me try one more time with corrected commands:


ContributorsGrid component is properly implemented with type safety

The component exists at the correct location and implements proper type checking with:

  • ContributorData type defining the shape of contributor data
  • ContributorsGridProps interface for component props
  • Correct usage of TypeScript types in the component implementation
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if ContributorsGrid component exists and has proper types
echo "Checking ContributorsGrid component..."
ast-grep --pattern 'interface ContributorData {
  $$$
}'

echo "Checking component implementation..."
ast-grep --pattern 'export default function ContributorsGrid({ data }: { data: ContributorData[] }) {
  $$$
}'

Length of output: 341


Script:

#!/bin/bash
# Check for the Colloborators component file
echo "Searching for Colloborators component file..."
fd "Colloborators.tsx"

# Check the content of the component if found
echo -e "\nChecking component implementation..."
rg -A 10 "export default function" --type typescript apps/www/components/custom/Colloborators.tsx

# Check for any type definitions
echo -e "\nChecking type definitions..."
rg "interface|type.*=.*{" --type typescript apps/www/components/custom/Colloborators.tsx

Length of output: 660


Script:

#!/bin/bash
# Check the content of the Colloborators component
echo "Checking component content..."
cat apps/www/components/custom/Colloborators.tsx

# Alternative search for type definitions with fixed regex
echo -e "\nChecking type definitions..."
rg "interface|type.*=" apps/www/components/custom/Colloborators.tsx

Length of output: 3945

apps/www/package.json (1)

35-35: LGTM: Cache dependency addition

The addition of @repo/cache workspace dependency aligns with the PR's objective for handling contributor data caching.

apps/www/app/(routes)/about/page.tsx (1)

51-51: LGTM: Clean integration of ContributorsGridWrapper

The ContributorsGridWrapper is well-positioned within the existing layout structure, maintaining consistency with the page's design.

apps/www/components/custom/ColloboratorGridWrapper.tsx Outdated Show resolved Hide resolved
apps/www/components/custom/ColloboratorGridWrapper.tsx Outdated Show resolved Hide resolved
apps/www/components/custom/ColloboratorGridWrapper.tsx Outdated Show resolved Hide resolved
apps/www/app/api/getDummyData.ts Outdated Show resolved Hide resolved
apps/www/app/(routes)/about/page.tsx Outdated Show resolved Hide resolved
apps/triggers/src/collaborator.status.ts Outdated Show resolved Hide resolved
apps/triggers/src/collaborator.status.ts Outdated Show resolved Hide resolved
apps/triggers/src/collaborator.status.ts Outdated Show resolved Hide resolved
apps/www/components/custom/Colloborators.tsx Outdated Show resolved Hide resolved
apps/www/components/custom/Colloborators.tsx Outdated Show resolved Hide resolved
Copy link
Member

@SkidGod4444 SkidGod4444 left a comment

Choose a reason for hiding this comment

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

@ayushhunt Make the changes as requested along with code rabbit bot!

apps/triggers/trigger.config.ts Outdated Show resolved Hide resolved
apps/www/app/api/getDummyData.ts Outdated Show resolved Hide resolved
apps/www/app/api/getDummyData.ts Outdated Show resolved Hide resolved
apps/www/app/layout.tsx Outdated Show resolved Hide resolved
packages/crypt/tsconfig.tsbuildinfo Outdated Show resolved Hide resolved
@SkidGod4444
Copy link
Member

Appropriate file/var names are strictly prohibited. Everything should be logical, @ayushhunt

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (7)
apps/triggers/src/collaborator.status.ts (3)

49-49: Fix operator spacing

Add spaces around the <= operator for consistency.

-      } while (page <=MAX_PAGES);
+      } while (page <= MAX_PAGES);

52-56: Enhance bot filtering logic

Consider adding more comprehensive bot detection patterns and making the filter rules configurable.

       const filteredContributors = contributors.filter(
         (contributor) =>
           contributor.type !== 'Bot' &&
-          !contributor.login.toLowerCase().includes('bot')
+          !contributor.login.toLowerCase().match(/(bot|[._-]bot|\\[bot\\]|automated)/)
       );

67-74: Add TTL to Redis cache

Consider adding an expiration time to the Redis key to prevent stale data accumulation.

       const redisKey = 'contributors';
       try {
         await cache.del(redisKey); // Clear existing data
         await cache.rpush(redisKey, ...contributorData.map((c) => JSON.stringify(c)));
+        await cache.expire(redisKey, 60 * 60 * 24 * 7); // 7 days TTL
       } catch (error) {
         logger.error('Failed to store contributors in Redis', { error });
         throw error; // Re-throw to trigger task retry
       }
apps/www/components/custom/Collaborators.tsx (4)

1-6: Add error boundary for client-side component.

Since this is a client-side component that fetches and displays external data, consider implementing an error boundary to gracefully handle runtime errors.

import { ErrorBoundary } from 'react-error-boundary';

function ErrorFallback({ error }: { error: Error }) {
  return (
    <div className="text-red-500">
      <p>Something went wrong:</p>
      <pre>{error.message}</pre>
    </div>
  );
}

21-22: Enhance grid accessibility and responsiveness.

The grid layout could benefit from improved accessibility and responsive design:

  1. Add ARIA labels for better screen reader support
  2. Consider adjusting container padding for smaller screens
-      <div className="container mx-auto px-12 py-8">
+      <div className="container mx-auto px-4 sm:px-8 md:px-12 py-8" role="region" aria-label="Contributors">
-        <div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4">
+        <div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4" role="list">

58-72: Extract duplicate avatar logic into a reusable component.

The avatar rendering logic is duplicated between the main view and tooltip. Consider extracting it into a reusable component.

type ContributorAvatarProps = {
  contributor: ContributorData;
  size: number;
};

function ContributorAvatar({ contributor, size }: ContributorAvatarProps) {
  return (
    <Avatar.Root className={`w-${size} h-${size} rounded-full overflow-hidden`}>
      {contributor.avatar_url ? (
        <Image
          src={contributor.avatar_url}
          alt={contributor.login}
          width={size * 4}
          height={size * 4}
          className="object-cover w-full h-full"
          loading="lazy"
        />
      ) : (
        <Avatar.Fallback className="flex items-center justify-center w-full h-full bg-gray-700 text-white text-sm">
          {contributor.login.charAt(0).toUpperCase()}
        </Avatar.Fallback>
      )}
    </Avatar.Root>
  );
}

23-88: Add loading states for better user experience.

Consider adding loading states while contributor data is being fetched:

if (!data.length) {
  return (
    <div className="flex justify-center items-center min-h-[200px]">
      <div className="animate-spin rounded-full h-8 w-8 border-t-2 border-b-2 border-blue-500" />
    </div>
  );
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 5c1b905 and 7f532e1.

📒 Files selected for processing (6)
  • apps/triggers/src/collaborator.status.ts (1 hunks)
  • apps/www/app/(routes)/about/page.tsx (2 hunks)
  • apps/www/app/layout.tsx (1 hunks)
  • apps/www/components/custom/Collaborators.tsx (1 hunks)
  • apps/www/components/custom/ColloboratorGridWrapper.tsx (1 hunks)
  • packages/crypt/.gitignore (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/crypt/.gitignore
🚧 Files skipped from review as they are similar to previous changes (3)
  • apps/www/app/(routes)/about/page.tsx
  • apps/www/app/layout.tsx
  • apps/www/components/custom/ColloboratorGridWrapper.tsx
🔇 Additional comments (3)
apps/triggers/src/collaborator.status.ts (2)

1-8: LGTM: Task configuration is well-structured

The imports are appropriate, and the task configuration with weekly schedule and 60-second duration is reasonable.


9-11: Move repository details to configuration

The repository owner and name are hardcoded. These should be moved to environment variables or configuration.

apps/www/components/custom/Collaborators.tsx (1)

18-93: Overall implementation looks good with room for improvements.

The component successfully implements the contributor grid with proper tooltips and fallbacks. Consider implementing the suggested improvements for better accessibility, performance, and maintainability.

apps/triggers/src/collaborator.status.ts Outdated Show resolved Hide resolved
apps/www/components/custom/Collaborators.tsx Outdated Show resolved Hide resolved
apps/www/components/custom/Collaborators.tsx Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (2)
apps/www/components/custom/Collaborators.tsx (2)

21-22: Consider improving responsive layout.

The current padding might be too large for mobile devices, and the container could benefit from a max-width for larger screens.

-      <div className="container mx-auto px-12 py-8">
+      <div className="container mx-auto px-4 sm:px-8 md:px-12 py-8 max-w-7xl">

64-70: Ensure consistent styling between main view and tooltip avatars.

The Image component in the tooltip is missing the background color and error handling present in the main view.

 <Image
   src={contributor.avatar_url}
   alt={contributor.login}
   width={32}
   height={32}
-  className="object-cover w-full h-full"
+  className="object-cover w-full h-full bg-gray-700"
+  loading="lazy"
+  onError={(e) => {
+    e.currentTarget.src = `/fallback-avatar.png`;
+  }}
 />
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 7f532e1 and 75b3684.

📒 Files selected for processing (2)
  • apps/triggers/src/collaborator.status.ts (1 hunks)
  • apps/www/components/custom/Collaborators.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/triggers/src/collaborator.status.ts
🔇 Additional comments (1)
apps/www/components/custom/Collaborators.tsx (1)

1-16: LGTM! Well-structured type definitions and imports.

The type definitions are clear and the required fields are properly enforced.

@@ -0,0 +1,97 @@
'use client';
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

File name should match the exported component name.

The file is named Collaborators.tsx but exports ContributorsGrid. For consistency and logical naming (as mentioned in PR objectives), consider renaming the file to ContributorsGrid.tsx.

Comment on lines 28 to 75
{contributor.avatar_url ? (
<Image
src={contributor.avatar_url}
alt={contributor.login}
width={40}
height={40}
className="object-cover w-full h-full bg-gray-700"
loading="lazy"
onError={(e) => {
e.currentTarget.src = `/fallback-avatar.png`;
}}
/>
) : (
<Avatar.Fallback className="flex items-center justify-center w-full h-full bg-gray-700 text-white text-sm">
{contributor.login.charAt(0).toUpperCase()}
</Avatar.Fallback>
)}
</Avatar.Root>
<a
href={contributor.html_url}
target="_blank"
rel="noopener noreferrer"
className="text-sm font-medium text-gray-300 hover:text-blue-400"
>
{contributor.login}
</a>
</div>
</Tooltip.Trigger>
<Tooltip.Content
side="top"
align="center"
className="px-4 py-2 bg-black text-white text-sm rounded shadow-lg"
>
<div className="flex items-center">
<Avatar.Root className="w-8 h-8 rounded-full overflow-hidden mr-3">
{contributor.avatar_url ? (
<Image
src={contributor.avatar_url}
alt={contributor.login}
width={32}
height={32}
className="object-cover w-full h-full"
/>
) : (
<Avatar.Fallback className="flex items-center justify-center w-full h-full bg-gray-700 text-white text-sm">
{contributor.login.charAt(0).toUpperCase()}
</Avatar.Fallback>
)}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Reduce code duplication in avatar rendering.

The Image and Avatar.Fallback components are duplicated between the main view and tooltip. Consider extracting this into a reusable component.

+const ContributorAvatar = ({ 
+  avatar_url, 
+  login, 
+  size = 40 
+}: { 
+  avatar_url?: string; 
+  login: string; 
+  size?: number 
+}) => (
+  <Avatar.Root className={`w-${size/4} h-${size/4} rounded-full overflow-hidden`}>
+    {avatar_url ? (
+      <Image
+        src={avatar_url}
+        alt={login}
+        width={size}
+        height={size}
+        className="object-cover w-full h-full bg-gray-700"
+        loading="lazy"
+        onError={(e) => {
+          e.currentTarget.src = `/fallback-avatar.png`;
+        }}
+      />
+    ) : (
+      <Avatar.Fallback className="flex items-center justify-center w-full h-full bg-gray-700 text-white text-sm">
+        {login.charAt(0).toUpperCase()}
+      </Avatar.Fallback>
+    )}
+  </Avatar.Root>
+);

// Usage:
-<Avatar.Root className="w-10 h-10 rounded-full overflow-hidden border border-gray-600">
-  {contributor.avatar_url ? (
-    <Image ... />
-  ) : (
-    <Avatar.Fallback ... />
-  )}
-</Avatar.Root>
+<ContributorAvatar 
+  avatar_url={contributor.avatar_url} 
+  login={contributor.login} 
+  size={40} 
+/>

Committable suggestion skipped: line range outside the PR's diff.

Copy link
Member

@SkidGod4444 SkidGod4444 left a comment

Choose a reason for hiding this comment

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

@ayushhunt 2 more changes along with code rabbit warnings!

}));

// Store data in Redis under a fixed key
const redisKey = 'contributors';
Copy link
Member

Choose a reason for hiding this comment

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

What is redis key?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

Copy link
Member

Choose a reason for hiding this comment

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

Why are we still having this file on your pr?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i have added it to gitignore

Copy link

@coderabbitai coderabbitai bot left a 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 (6)
apps/api/app/api/[[...route]]/contributors.ts (2)

5-10: Handle Empty or Missing Contributor Data Gracefully

If the contributorsData retrieved from the cache is null or empty, the API response will include null or an empty array. Consider initializing contributorsData to an empty array if it's null to ensure consistent API responses.

Apply this diff to handle the case:

 .get("/", async (c) => {
     const contributorsData = await cache.lrange("contributors", 0, -1);
+    const data = contributorsData ? contributorsData : [];
     return c.json({
-        contributorsData
+        contributorsData: data
     });
   })

5-10: Set Appropriate Cache Headers for API Responses

To improve client-side caching and reduce unnecessary API calls, consider setting cache control headers in the response.

Apply this diff to add cache headers:

 .get("/", async (c) => {
     const contributorsData = await cache.lrange("contributors", 0, -1);
     return c.json({
         contributorsData
+    }, 200, {
+        'Cache-Control': 'public, max-age=300' // Cache for 5 minutes
+    });
   })
apps/api/app/api/[[...route]]/route.ts (1)

11-12: Maintain Consistent Import Formatting

For better readability, maintain consistent formatting for your import statements, especially when adding new imports.

Apply this diff to alphabetize the imports:

 import status from "./status";
 import user from "./user";
+import contributors from "./contributors";
 import { cors } from "hono/cors";
apps/www/components/custom/contributors-grid.tsx (2)

28-39: Improve Accessibility by Adding ARIA Labels

To enhance accessibility for users relying on assistive technologies, consider adding ARIA labels to interactive elements like avatars and contributor names.

Apply this diff to add ARIA labels:

               <div className="flex items-center gap-4 p-4 rounded-lg shadow-sm hover:shadow-md transition-all">
                 <Avatar className="w-10 h-10">
                   <AvatarImage
                     src={contributor.avatar_url}
                     alt={contributor.login}
+                    aria-label={`Avatar of ${contributor.login}`}
                     className="rounded-full"
                   />
                   <AvatarFallback>
                     {contributor.login.charAt(0).toUpperCase()}
                   </AvatarFallback>
                 </Avatar>
                 <p className="text-sm font-medium">{contributor.login}</p>
               </div>

26-65: Avoid Using Index as Key in Lists

In React, using the index as a key can lead to issues. Since contributor.id is available and unique, it's better to use it as the key.

No action needed as you're already using contributor.id as the key.

apps/www/app/(routes)/about/page.tsx (1)

28-29: Remove Console Logs in Production Code

The console.log statements can clutter the console and may expose sensitive data. Remove them before deploying.

Apply this diff to remove the console logs:

     const data = await response.json();
-    console.log(data);
     setContributors(data.contributorsData);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 75b3684 and 778dcc8.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (7)
  • apps/api/app/api/[[...route]]/contributors.ts (1 hunks)
  • apps/api/app/api/[[...route]]/route.ts (2 hunks)
  • apps/api/next.config.js (1 hunks)
  • apps/triggers/src/contributors.ts (1 hunks)
  • apps/www/app/(routes)/about/page.tsx (3 hunks)
  • apps/www/components/custom/contributors-grid.tsx (1 hunks)
  • apps/www/package.json (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/api/next.config.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/www/package.json
🔇 Additional comments (1)
apps/www/app/(routes)/about/page.tsx (1)

72-74: Address Previous Review Comment: Unused Imports

As previously mentioned, ensure that all imports are used or removed to maintain clean code.

Comment on lines +4 to +9
type ContributorData = {
login: string;
id: number;
avatar_url?: string;
html_url: string;
};
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Ensure Consistency Between Type Definition and Mapped Data

There's a mismatch between the ContributorData type and how you're mapping the data in contributorData. The type defines html_url, but the mapped data uses github_link. To maintain consistency and avoid potential issues, align the property names.

Apply this diff to update the type definition:

 type ContributorData = {
   login: string;
   id: number;
   avatar_url?: string;
-  html_url: string;
+  github_link: string;
 };

Also applies to: 65-70

Comment on lines +25 to +28
if (page > MAX_PAGES) {
logger.warn(`Reached maximum page limit of ${MAX_PAGES}`);
break;
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Simplify Loop Structure to Eliminate Redundant Checks

The if (page > MAX_PAGES) check inside the loop is redundant since the loop condition already handles it. Simplify the loop by removing the redundant check and converting the do...while loop to a while loop for clarity.

Apply this diff to refactor the loop:

- do {
-   // ... your code ...
-   if (page > MAX_PAGES) {
-     logger.warn(`Reached maximum page limit of ${MAX_PAGES}`);
-     break;
-   }
-   // ... your code ...
-   page += 1;
- } while (page <= MAX_PAGES);
+ while (page <= MAX_PAGES) {
+   // ... your code ...
+   // ... your code ...
+   page += 1;
+ }

Also applies to: 56-56

Comment on lines +38 to +42
const rateLimit = response.headers.get('x-ratelimit-remaining');
if (rateLimit === '0') {
logger.error('GitHub API rate limit exceeded');
return;
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Parse Rate Limit Header as an Integer for Accurate Comparison

Currently, the rate limit is compared as a string, which can lead to incorrect behavior if the header is missing or not exactly '0'. Parse the header value as an integer to ensure accurate comparison.

Apply this diff to fix the issue:

- const rateLimit = response.headers.get('x-ratelimit-remaining');
- if (rateLimit === '0') {
+ const rateLimit = parseInt(response.headers.get('x-ratelimit-remaining') || '0', 10);
+ if (rateLimit === 0) {
    logger.error('GitHub API rate limit exceeded');
    return;
  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const rateLimit = response.headers.get('x-ratelimit-remaining');
if (rateLimit === '0') {
logger.error('GitHub API rate limit exceeded');
return;
}
const rateLimit = parseInt(response.headers.get('x-ratelimit-remaining') || '0', 10);
if (rateLimit === 0) {
logger.error('GitHub API rate limit exceeded');
return;
}

Comment on lines +11 to +12
import contributors from "./contributors"
import { cors } from "hono/cors";
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Avoid Hardcoding Origins in CORS Configuration

Hardcoding the origin ('http://localhost:3003') in the CORS middleware can lead to issues when deploying to production. Consider using an environment variable or a configuration setting to manage allowed origins dynamically.

Apply this diff to use an environment variable:

 import { cors } from "hono/cors";

 app.use(
   '*',
   cors({
-    origin: 'http://localhost:3003', // Allow requests from your frontend origin
+    origin: process.env.FRONTEND_ORIGIN || 'http://localhost:3003',
     allowMethods: ['GET', 'POST', 'OPTIONS'],
   })
 );

 app.route("/contributors", contributors);

Also applies to: 23-29, 38-38

Comment on lines 26 to 29
const response = await fetch("http://localhost:3001/api/contributors");
const data = await response.json();
console.log(data);
setContributors(data.contributorsData);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Use Environment Variables for API Endpoints

The API endpoint 'http://localhost:3001/api/contributors' is hardcoded, which can cause issues when deploying to different environments. Use environment variables to manage API endpoints dynamically.

Apply this diff to use an environment variable:

 const fetchContributors = async () => {
   try{
-    const response = await fetch("http://localhost:3001/api/contributors");
+    const response = await fetch(`${process.env.NEXT_PUBLIC_API_BASE_URL}/contributors`);
     const data = await response.json();
     console.log(data);
     setContributors(data.contributorsData);

Ensure that NEXT_PUBLIC_API_BASE_URL is defined in your environment variables.

Committable suggestion skipped: line range outside the PR's diff.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (1)
apps/www/app/(routes)/about/page.tsx (1)

21-25: Consider using environment variables for both URLs

While the environment check is good, consider using environment variables for both development and production URLs to maintain consistency and flexibility.

  const fetchUrl =
    process.env.NODE_ENV === 'production'
-     ? 'https://app.plura.pro/api/contributors'
-     : 'http://localhost:3001/api/contributors';
+     ? `${process.env.NEXT_PUBLIC_API_URL}/api/contributors`
+     : `${process.env.NEXT_PUBLIC_DEV_API_URL}/api/contributors`;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 778dcc8 and 3fe8035.

📒 Files selected for processing (1)
  • apps/www/app/(routes)/about/page.tsx (3 hunks)
🔇 Additional comments (2)
apps/www/app/(routes)/about/page.tsx (2)

Line range hint 1-18: LGTM! Clean imports and well-defined types

The ContributorData type is well-structured with appropriate optional fields, and all imports are being used in the component.


2-2: Verify ContributorsGrid component implementation

Let's verify that the ContributorsGrid component exists and accepts the correct props type.

Also applies to: 78-78

✅ Verification successful

ContributorsGrid component implementation verified successfully

The component exists and is properly implemented with:

  • Correct props interface accepting data: ContributorData[]
  • Proper type definition for ContributorData
  • Correct usage in about/page.tsx with the expected data prop
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if ContributorsGrid component exists and verify its props interface
ast-grep --pattern 'interface $props {
  data: $type[];
}' apps/www/components/custom/contributors-grid.tsx

# Check for any existing error handling in the component
rg -A 5 'data.length === 0' apps/www/components/custom/contributors-grid.tsx

Length of output: 188


Script:

#!/bin/bash
# Let's first check if the component file exists
fd "contributors-grid" apps/www

# If it exists, let's examine its content
fd "contributors-grid" apps/www --exec cat {}

# Let's also search for any usage of ContributorsGrid to understand the props being passed
rg "ContributorsGrid" -A 3 apps/www

Length of output: 3758

</div>
<ContributorsGrid data={contributors}/>
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add conditional rendering for loading and error states

The ContributorsGrid should handle different states appropriately.

- <ContributorsGrid data={contributors}/>
+ {error && <div className="text-red-500">{error}</div>}
+ {isLoading ? (
+   <div>Loading contributors...</div>
+ ) : (
+   <ContributorsGrid data={contributors}/>
+ )}

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +27 to +39
useEffect(() => {
const fetchContributors = async () => {
try{
const response = await fetch(fetchUrl);
const data = await response.json();
console.log(data);
setContributors(data.contributorsData);
}catch (e){
console.log(e);
}
};
fetchContributors();
}, []);
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance error handling and add loading state

The current implementation has several areas for improvement:

  1. Remove console.log statements or use proper logging
  2. Add loading state management
  3. Implement more robust error handling
+ const [isLoading, setIsLoading] = useState(false);
+ const [error, setError] = useState<string | null>(null);

  useEffect(() => {
    const fetchContributors = async () => {
+     setIsLoading(true);
+     setError(null);
      try {
        const response = await fetch(fetchUrl);
+       if (!response.ok) {
+         throw new Error(`HTTP error! status: ${response.status}`);
+       }
        const data = await response.json();
-       console.log(data);
        setContributors(data.contributorsData);
      } catch (e) {
-       console.log(e);
+       setError(e instanceof Error ? e.message : 'Failed to fetch contributors');
+     } finally {
+       setIsLoading(false);
      }
    };
    fetchContributors();
  }, []);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
useEffect(() => {
const fetchContributors = async () => {
try{
const response = await fetch(fetchUrl);
const data = await response.json();
console.log(data);
setContributors(data.contributorsData);
}catch (e){
console.log(e);
}
};
fetchContributors();
}, []);
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
useEffect(() => {
const fetchContributors = async () => {
setIsLoading(true);
setError(null);
try {
const response = await fetch(fetchUrl);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
setContributors(data.contributorsData);
} catch (e) {
setError(e instanceof Error ? e.message : 'Failed to fetch contributors');
} finally {
setIsLoading(false);
}
};
fetchContributors();
}, []);

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (1)
apps/triggers/src/contributors.ts (1)

59-62: Enhance Bot Detection Logic

The current bot detection might miss some cases. GitHub provides a type field that explicitly identifies bot accounts.

       const filteredContributors = contributors.filter(
         (contributor) =>
-          !contributor.login.toLowerCase().includes('bot')
+          contributor.type !== 'Bot' && !contributor.login.toLowerCase().includes('bot')
       );
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 3fe8035 and 844a04f.

📒 Files selected for processing (1)
  • apps/triggers/src/contributors.ts (1 hunks)
🔇 Additional comments (4)
apps/triggers/src/contributors.ts (4)

4-9: Ensure Consistency Between Type Definition and Mapped Data

There's a mismatch between the ContributorData type and how you're mapping the data in contributorData. The type defines html_url, but the mapped data uses github_link.


24-28: Simplify Loop Structure to Eliminate Redundant Checks

The if (page > MAX_PAGES) check inside the loop is redundant since the loop condition already handles it.

Also applies to: 56-56


38-42: Parse Rate Limit Header as an Integer for Accurate Comparison

Currently, the rate limit is compared as a string, which can lead to incorrect behavior if the header is missing or not exactly '0'.


11-14: Consider Increasing Task Duration for Large Repositories

The 60-second duration limit might be insufficient for repositories with many contributors, especially since you're fetching up to 1000 contributors (10 pages × 100 per page).

Consider increasing maxDuration to 180 seconds to handle potential API delays and rate limiting.

Comment on lines +16 to +18
const owner = 'SkidGod4444'; // Replace with the repository owner's username
const repo = 'plura'; // Replace with the repository name
const GITHUB_TOKEN = process.env.GITHUB_TOKEN;
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Move Repository Configuration to Environment Variables

Hardcoding repository details reduces reusability and makes maintenance harder. Consider moving these to environment variables.

-    const owner = 'SkidGod4444'; // Replace with the repository owner's username
-    const repo = 'plura'; // Replace with the repository name
+    const owner = process.env.GITHUB_REPO_OWNER;
+    const repo = process.env.GITHUB_REPO_NAME;

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +74 to +80
try {
await cache.del(redisKey);
await cache.rpush(redisKey, ...contributorData.map((c) => JSON.stringify(c)));
} catch (error) {
logger.error('Failed to store contributors in Redis', { error });
throw error;
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Use Atomic Operations for Redis Updates

The current implementation has a potential race condition between deleting and pushing new data. Consider using a transaction or a single atomic operation.

-        await cache.del(redisKey); 
-        await cache.rpush(redisKey, ...contributorData.map((c) => JSON.stringify(c)));
+        const pipeline = cache.pipeline();
+        pipeline.del(redisKey);
+        pipeline.rpush(redisKey, ...contributorData.map((c) => JSON.stringify(c)));
+        await pipeline.exec();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
try {
await cache.del(redisKey);
await cache.rpush(redisKey, ...contributorData.map((c) => JSON.stringify(c)));
} catch (error) {
logger.error('Failed to store contributors in Redis', { error });
throw error;
}
try {
const pipeline = cache.pipeline();
pipeline.del(redisKey);
pipeline.rpush(redisKey, ...contributorData.map((c) => JSON.stringify(c)));
await pipeline.exec();
} catch (error) {
logger.error('Failed to store contributors in Redis', { error });
throw error;
}

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 844a04f and 824e749.

📒 Files selected for processing (1)
  • apps/api/app/api/[[...route]]/route.ts (2 hunks)
🔇 Additional comments (3)
apps/api/app/api/[[...route]]/route.ts (3)

45-45: LGTM: Route registration follows established patterns

The contributors route is correctly registered and follows the same pattern as other routes in the file.


23-27: 🛠️ Refactor suggestion

Move CORS origins to environment configuration

Hardcoding the origins can cause deployment issues and make environment management difficult.

Apply this diff to use environment variables:

-const allowedOrigins = [
-  "http://localhost:3003",
-  "https://www.plura.pro",
-  "https://app.plura.pro",
-];
+const allowedOrigins = (process.env.ALLOWED_ORIGINS || "http://localhost:3003")
+  .split(",")
+  .map(origin => origin.trim());

11-12: Verify the existence of the contributors route file

The imports look correct, but let's verify the existence of the contributors file.

✅ Verification successful

Import path is valid and file exists

The contributors.ts file exists at the expected location apps/api/app/api/[[...route]]/contributors.ts, confirming that the import statement is correct and valid.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of the contributors route file
# Expected: Find the contributors.ts file in the same directory

fd -t f "contributors.ts" "apps/api/app/api/[[...route]]"

Length of output: 103

Comment on lines +30 to +36
app.use(
'*',
cors({
origin: allowedOrigins, // Allow requests from your frontend origin
allowMethods: ['GET', 'POST', 'OPTIONS'],
})
);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Review CORS security configuration

There are several security considerations in the current CORS setup:

  1. Using '*' as the path matches all routes, potentially exposing sensitive endpoints
  2. The limited allowMethods might restrict necessary API functionality

Consider these improvements:

  1. Use specific paths instead of '*' for CORS
  2. Add other necessary HTTP methods (like PATCH, DELETE) that your API uses
  3. Add additional security headers
 app.use(
-  '*',
+  '/api/*',
   cors({
     origin: allowedOrigins,
-    allowMethods: ['GET', 'POST', 'OPTIONS'],
+    allowMethods: ['GET', 'POST', 'PATCH', 'DELETE', 'OPTIONS'],
+    allowHeaders: ['Content-Type', 'Authorization'],
+    maxAge: 600, // Cache preflight requests for 10 minutes
   })
 );
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
app.use(
'*',
cors({
origin: allowedOrigins, // Allow requests from your frontend origin
allowMethods: ['GET', 'POST', 'OPTIONS'],
})
);
app.use(
'/api/*',
cors({
origin: allowedOrigins,
allowMethods: ['GET', 'POST', 'PATCH', 'DELETE', 'OPTIONS'],
allowHeaders: ['Content-Type', 'Authorization'],
maxAge: 600, // Cache preflight requests for 10 minutes
})
);

@SkidGod4444 SkidGod4444 merged commit 1c66f00 into plura-ai:main Dec 2, 2024
12 of 15 checks passed
@ayushhunt ayushhunt deleted the feat/collabsection branch December 2, 2024 16:09
This was referenced Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Collobarators section
3 participants