Skip to content

Conversation

yshashi
Copy link
Collaborator

@yshashi yshashi commented Sep 14, 2025

Summary by CodeRabbit

  • New Features

    • Environment-aware API base URL automatically selects the correct endpoint for development and production.
    • Eliminates hardcoded URLs, improving reliability across environments.
  • Refactor

    • Updated authentication and events API services to use a centralized, injected base URL for all requests.
  • Chores

    • Configured application to provide the base API URL via dependency injection, enabling consistent URL resolution without manual setup.

Copy link

coderabbitai bot commented Sep 14, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Introduces a DI token and factory for the base API URL, wires it into the app providers, and updates auth and event services to use the injected base URL instead of hard-coded endpoints.

Changes

Cohort / File(s) Summary
App configuration
apps/frontend/src/app/app.config.ts
Registers BASE_API_URL provider using useFactory: getBaseApiUrl.
Base API URL context (new)
apps/frontend/src/app/shared/context/base-api-url.ts
Adds BASE_API_URL InjectionToken and getBaseApiUrl() that computes URL based on window and isDevMode().
Services updated to injected base URL
apps/frontend/src/app/shared/services/auth-api.ts, apps/frontend/src/app/shared/services/event-api.ts
Inject BASE_API_URL; replace hard-coded URLs with ${baseUrl}/auth and ${baseUrl}/events; preserve public APIs.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User (Browser)
  participant A as Angular App
  participant DI as DI Container
  participant S1 as AuthApiService
  participant S2 as EventApiService
  participant H as HttpClient
  participant API as Backend API

  U->>A: Load application
  A->>DI: Resolve BASE_API_URL
  activate DI
  DI-->>A: BASE_API_URL via getBaseApiUrl()
  deactivate DI

  U->>S1: Sign in/out actions
  S1->>H: HTTP to {BASE_API_URL}/auth/...
  H-->>API: Request
  API-->>H: Response
  H-->>S1: Response

  U->>S2: View events
  S2->>H: HTTP to {BASE_API_URL}/events/all
  H-->>API: Request
  API-->>H: Response
  H-->>S2: Response

  note over DI,A: getBaseApiUrl() computes URL using window + isDevMode()
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A hop and a skip through URLs we go,
No more hard-coded paths in tow!
With tokens we bind, and factories find,
The right base all of the time.
Carrot-powered calls now neatly align—
Thump-thump, ship it, it’s sublime! 🥕✨

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/update-base-api-url

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9534995 and b3b18e4.

📒 Files selected for processing (4)
  • apps/frontend/src/app/app.config.ts (1 hunks)
  • apps/frontend/src/app/shared/context/base-api-url.ts (1 hunks)
  • apps/frontend/src/app/shared/services/auth-api.ts (1 hunks)
  • apps/frontend/src/app/shared/services/event-api.ts (1 hunks)

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@santoshyadavdev santoshyadavdev merged commit f282e7d into main Sep 14, 2025
0 of 2 checks passed
@santoshyadavdev santoshyadavdev deleted the feature/update-base-api-url branch September 14, 2025 15:52
Copy link

nx-cloud bot commented Sep 14, 2025

🤖 Nx Cloud AI Fix Eligible

An automatically generated fix could have helped fix failing tasks for this run, but Self-healing CI is disabled for this workspace. Visit workspace settings to enable it and get automatic fixes in future runs.

To disable these notifications, a workspace admin can disable them in workspace settings.


View your CI Pipeline Execution ↗ for commit b3b18e4

Command Status Duration Result
nx affected -t lint test build ❌ Failed 13s View ↗

☁️ Nx Cloud last updated this comment at 2025-09-14 15:56:03 UTC

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.

2 participants