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

chore(consultation-portal): Move to ts, and use API_URL #17133

Merged
merged 5 commits into from
Dec 4, 2024

Conversation

AndesKrrrrrrrrrrr
Copy link
Member

@AndesKrrrrrrrrrrr AndesKrrrrrrrrrrr commented Dec 4, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a local environment variable for authentication URL to enhance local development.
    • Added a new proxy configuration file to manage API requests dynamically.
  • Bug Fixes

    • Removed outdated proxy configuration file to streamline setup.
  • Refactor

    • Updated import method for proxy configuration to improve flexibility and maintainability.

@AndesKrrrrrrrrrrr AndesKrrrrrrrrrrr added the automerge Merge this PR as soon as all checks pass label Dec 4, 2024
Copy link
Contributor

coderabbitai bot commented Dec 4, 2024

Walkthrough

The changes in this pull request involve updates to the environment variable configuration for local development, the introduction of a new proxy configuration file, and a modification of the import statement for the proxy configuration in the server file. Specifically, the NEXTAUTH_URL now includes a local entry, a new TypeScript file replaces a previously existing JSON configuration for the proxy, and the server file imports the new configuration instead of the old JSON file.

Changes

File Change Summary
apps/consultation-portal/infra/samradsgatt.ts Added local entry to NEXTAUTH_URL in serviceSetup function pointing to the local development URL.
apps/consultation-portal/proxy.config.json Deleted the proxy configuration JSON file that directed API requests to a GraphQL endpoint.
apps/consultation-portal/proxy.config.ts Introduced new proxy.config.ts file with a proxyConfig object for API proxy configuration.
apps/consultation-portal/server.ts Modified import statement to load proxyConfig from the new TypeScript file instead of the JSON file.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Server
    participant Proxy

    Client->>Server: Request to /api/graphql
    Server->>Proxy: Forward request to /api/graphql
    Proxy->>Proxy: Check API_URL
    alt API_URL is set
        Proxy->>Proxy: Use API_URL as target
    else API_URL is not set
        Proxy->>Proxy: Default to http://localhost:4444
    end
    Proxy->>Target: Forward request to target server
    Target-->>Proxy: Response
    Proxy-->>Server: Forward response
    Server-->>Client: Send response
Loading

Suggested reviewers

  • busla

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 87f5006 and 0087f5f.

📒 Files selected for processing (1)
  • apps/consultation-portal/infra/samradsgatt.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/consultation-portal/infra/samradsgatt.ts

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.

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.

@AndesKrrrrrrrrrrr AndesKrrrrrrrrrrr marked this pull request as ready for review December 4, 2024 15:44
@AndesKrrrrrrrrrrr AndesKrrrrrrrrrrr requested review from a team as code owners December 4, 2024 15:44
Copy link
Contributor

@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

🧹 Outside diff range and nitpick comments (1)
apps/consultation-portal/proxy.config.ts (1)

3-3: Add URL validation for API_URL environment variable

The API_URL is used without validation, which could lead to runtime issues if an invalid URL is provided.

+const validateUrl = (url: string): string => {
+  try {
+    new URL(url);
+    return url;
+  } catch {
+    return 'http://localhost:4444';
+  }
+};
+
 const proxyConfig: ProxyConfig = {
   '/api/graphql': {
-    target: process.env.API_URL ?? 'http://localhost:4444',
+    target: validateUrl(process.env.API_URL ?? 'http://localhost:4444'),
     secure: false,
   },
 }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 7c45c97 and 87f5006.

📒 Files selected for processing (4)
  • apps/consultation-portal/infra/samradsgatt.ts (1 hunks)
  • apps/consultation-portal/proxy.config.json (0 hunks)
  • apps/consultation-portal/proxy.config.ts (1 hunks)
  • apps/consultation-portal/server.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • apps/consultation-portal/proxy.config.json
🧰 Additional context used
📓 Path-based instructions (3)
apps/consultation-portal/proxy.config.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/consultation-portal/server.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/consultation-portal/infra/samradsgatt.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
🔇 Additional comments (2)
apps/consultation-portal/server.ts (1)

2-2: LGTM! Import statement follows TypeScript best practices

The import statement correctly omits the file extension, allowing TypeScript's module resolution to work properly.

apps/consultation-portal/infra/samradsgatt.ts (1)

31-31: LGTM! Local environment configuration follows established pattern

The added local environment URL maintains consistency with other environment configurations and follows the same path structure.

✅ Verification successful

URL pattern consistency verified across environments

The verification confirms that the local environment URL follows the same /samradsgatt/api/auth pattern consistently used across all environments (dev, staging, prod) and in the logout functionality.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify URL pattern consistency across the codebase
rg -g '*.ts' -g '*.js' '/samradsgatt/api/auth' --no-filename | sort -u

Length of output: 407

apps/consultation-portal/proxy.config.ts Show resolved Hide resolved
Copy link
Contributor

@advaniasteinar advaniasteinar left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

Copy link
Member

@brynjarorng brynjarorng left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

codecov bot commented Dec 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 35.74%. Comparing base (03e105f) to head (cb5f187).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #17133   +/-   ##
=======================================
  Coverage   35.74%   35.74%           
=======================================
  Files        6925     6925           
  Lines      147558   147558           
  Branches    42009    42009           
=======================================
  Hits        52745    52745           
  Misses      94813    94813           
Flag Coverage Δ
web 2.43% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
apps/consultation-portal/server.ts 0.00% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 03e105f...cb5f187. Read the comment docs.

@datadog-island-is
Copy link

Datadog Report

Branch report: chore/consultation-portal-proxyconfig
Commit report: 5d49526
Test service: web

✅ 0 Failed, 84 Passed, 0 Skipped, 33.66s Total Time
➡️ Test Sessions change in coverage: 1 no change

@kodiakhq kodiakhq bot merged commit ac5361c into main Dec 4, 2024
41 checks passed
@kodiakhq kodiakhq bot deleted the chore/consultation-portal-proxyconfig branch December 4, 2024 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants