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

fix(j-s): Missing path for defender API #17566

Merged
merged 3 commits into from
Jan 21, 2025
Merged

fix(j-s): Missing path for defender API #17566

merged 3 commits into from
Jan 21, 2025

Conversation

unakb
Copy link
Member

@unakb unakb commented Jan 20, 2025

What

Added path for defender endpoints

Why

So we can use the lawyer registry from our API layer

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

  • New Features
    • Added a new /api/defender endpoint to the Judicial System API
  • Infrastructure
    • Updated ingress configurations across development, staging, and production environments to include the new defender API path

@unakb unakb requested a review from a team as a code owner January 20, 2025 12:23
Copy link
Contributor

coderabbitai bot commented Jan 20, 2025

Walkthrough

This pull request introduces a new /api/defender path to the ingress configuration across multiple environment-specific configuration files for the Judicial System API. The change is consistently applied to development, staging, and production environments, adding the new endpoint to the existing routing configuration. The modification appears to be preparing infrastructure to support a new defender-related API endpoint.

Changes

File Change Summary
apps/judicial-system/api/infra/judicial-system-api.ts Added /api/defender to paths array in ingress configuration
charts/judicial-system/values.{dev,staging,prod}.yaml Added /api/defender path to ingress hosts configuration
charts/judicial-system-services/judicial-system-api/values.{dev,staging,prod}.yaml Added /api/defender path to primary-alb ingress configuration

Possibly related PRs

Suggested labels

automerge


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 30d1fb1 and 69a1a2f.

📒 Files selected for processing (3)
  • charts/judicial-system-services/judicial-system-api/values.dev.yaml (1 hunks)
  • charts/judicial-system-services/judicial-system-api/values.prod.yaml (1 hunks)
  • charts/judicial-system-services/judicial-system-api/values.staging.yaml (1 hunks)
🔇 Additional comments (4)
charts/judicial-system-services/judicial-system-api/values.dev.yaml (2)

Line range hint 1-5: Warning: This file should not be edited manually.

Please ensure you're using the yarn charts command to generate these files, as indicated by the warning comment.


74-74: LGTM! Path addition follows existing pattern.

The new /api/defender path is consistently added alongside existing API paths and aligns with the PR objective of integrating with the lawyer registry. The presence of LAWYERS_ICELAND_API_KEY secret supports this integration.

charts/judicial-system-services/judicial-system-api/values.prod.yaml (1)

74-74: LGTM! Production configuration is secure.

The /api/defender path is correctly added with AUTH_BYPASS disabled for production. The configuration maintains security while enabling the lawyer registry integration.

charts/judicial-system-services/judicial-system-api/values.staging.yaml (1)

74-74: LGTM! Staging configuration is consistent.

The /api/defender path addition maintains consistency across all environments. However, please ensure that the corresponding defender API implementation is ready for deployment.

Run this script to verify the defender API implementation:

✅ Verification successful

Defender API implementation is complete and ready for deployment

The /api/defender path addition is supported by a comprehensive implementation including:

  • Complete API endpoints in the digital-mailbox-api
  • Database schema with proper migrations
  • Frontend integration with GraphQL and UI components
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for the defender API implementation
# Look for controller/route handler files
rg -t ts -t js "defender.*\.(ts|js)" 

# Look for defender-related tests
rg -t ts -t js "defender.*\.test\.(ts|js)"

# Look for defender-related GraphQL schemas
rg -t graphql "type.*Defender|input.*Defender|enum.*Defender"

Length of output: 179


Script:

#!/bin/bash
# Search for any defender-related code
rg -i "defender" -g "!{*.md,*.yaml,*.yml}" -A 3

# Look for API route definitions
rg -i "router\.(get|post|put|delete).*defender" -g "!{*.md,*.yaml,*.yml}" -A 2

# Find GraphQL schema files and check content
fd -e graphql -x cat {}

Length of output: 105069


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6cd8e3a and 8c51600.

📒 Files selected for processing (1)
  • apps/judicial-system/api/infra/judicial-system-api.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
apps/judicial-system/api/infra/judicial-system-api.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 (1)
apps/judicial-system/api/infra/judicial-system-api.ts (1)

70-76: Documentation and tests need to be updated.

As mentioned in the PR objectives, please ensure:

  1. Documentation is updated to reflect the new defender endpoint
  2. Tests are added to validate the endpoint functionality

Would you like me to help create:

  • API documentation for the new endpoint?
  • Test cases to validate the integration?

Copy link

codecov bot commented Jan 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 35.58%. Comparing base (33c3794) to head (69a1a2f).
Report is 7 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #17566   +/-   ##
=======================================
  Coverage   35.57%   35.58%           
=======================================
  Files        7027     7027           
  Lines      150434   150421   -13     
  Branches    42943    42936    -7     
=======================================
  Hits        53522    53522           
+ Misses      96912    96899   -13     
Flag Coverage Δ
judicial-system-backend 55.84% <ø> (ø)
services-auth-admin-api 52.51% <ø> (ø)
services-auth-ids-api 52.55% <ø> (ø)
services-auth-public-api 49.40% <ø> (ø)
services-university-gateway 49.61% <ø> (+0.02%) ⬆️
services-user-notification 46.57% <ø> (ø)

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

see 7 files with indirect coverage changes


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 33c3794...69a1a2f. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Jan 20, 2025

Datadog Report

All test runs 8bca1c3 🔗

10 Total Test Services: 0 Failed, 10 Passed
🔻 Test Sessions change in coverage: 2 decreased, 1 increased (+0.1%), 197 no change

Test Services
This report shows up to 10 services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
air-discount-scheme-backend 0 0 0 63 0 22.15s N/A Link
air-discount-scheme-web 0 0 0 2 0 6.5s 1 no change Link
api 0 0 0 4 0 2.74s N/A Link
api-catalogue-services 0 0 0 23 0 9.18s N/A Link
api-domains-air-discount-scheme 0 0 0 6 0 16.43s N/A Link
api-domains-assets 0 0 0 3 0 9.53s N/A Link
api-domains-auth-admin 0 0 0 18 0 10.29s 1 no change Link
api-domains-communications 0 0 0 5 0 30.62s N/A Link
api-domains-criminal-record 0 0 0 5 0 8.42s N/A Link
api-domains-driving-license 0 0 0 23 0 27.14s N/A Link

🔻 Code Coverage Decreases vs Default Branch (2)

  • message-queue - jest 67.46% (-0.8%) - Details
  • services-user-profile - jest 49.33% (-0.02%) - Details

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: 0

🧹 Nitpick comments (1)
charts/judicial-system/values.dev.yaml (1)

74-74: LGTM! Consider adding API documentation.

The endpoint is properly configured in the judicial system chart. Consider documenting the new endpoint's purpose and usage in the API documentation.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8c51600 and 30d1fb1.

📒 Files selected for processing (6)
  • charts/judicial-system/values.dev.yaml (1 hunks)
  • charts/judicial-system/values.prod.yaml (1 hunks)
  • charts/judicial-system/values.staging.yaml (1 hunks)
  • charts/services/judicial-system-api/values.dev.yaml (1 hunks)
  • charts/services/judicial-system-api/values.prod.yaml (1 hunks)
  • charts/services/judicial-system-api/values.staging.yaml (1 hunks)
🔇 Additional comments (6)
charts/services/judicial-system-api/values.dev.yaml (1)

74-74: LGTM! Endpoint addition is consistent with existing configuration.

The new /api/defender path follows the established API endpoint pattern and is properly configured with the necessary security settings.

Verify that the endpoint is properly secured by checking for authentication middleware in the API implementation:

✅ Verification successful

Endpoint is properly secured with JWT authentication

The /api/defender endpoint is protected by JwtInjectBearerAuthGuard at the controller level, ensuring all routes require valid JWT authentication. The implementation follows secure coding practices with proper integration into the authentication system.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for authentication middleware usage
rg -A 5 "'/api/defender'" apps/judicial-system/api/src/

Length of output: 63


Script:

#!/bin/bash
# Search for defender endpoint and router configurations
rg -i "defender" apps/judicial-system/api/src/
rg -i "router.*defender|defender.*router" apps/judicial-system/api/src/

# Search for authentication middleware patterns
ast-grep --pattern 'router.use($$$)' apps/judicial-system/api/src/

Length of output: 14673


Script:

#!/bin/bash
# Search for authentication guards and middleware
ast-grep --pattern '@UseGuards($$$)' apps/judicial-system/api/src/app/modules/defender/
rg -A 5 "implements NestMiddleware" apps/judicial-system/api/src/app/modules/auth/
rg "bootstrap.*configure" apps/judicial-system/api/src/main.ts

Length of output: 352

charts/services/judicial-system-api/values.prod.yaml (1)

74-74: LGTM! Production configuration maintains security standards.

The endpoint addition is consistent with development environment and maintains production-grade security settings.

charts/services/judicial-system-api/values.staging.yaml (1)

74-74: LGTM! Staging configuration maintains environment parity.

The endpoint configuration ensures a smooth deployment pipeline from development through staging to production.

charts/judicial-system/values.staging.yaml (1)

74-74: LGTM! Configuration is complete and consistent.

The endpoint addition is properly implemented across all environments and chart configurations, successfully enabling the lawyer registry integration as intended.

charts/judicial-system/values.prod.yaml (2)

74-74: LGTM! The path addition looks correct.

The new path /api/defender is properly added to the ingress configuration, which aligns with the PR objective of integrating with the lawyer registry. The change follows the existing pattern and is minimal.

A few security considerations to note:

  1. The path is added to the external ALB ingress
  2. The service has access to LAWYERS_ICELAND_API_KEY
  3. Authentication is handled via the existing configuration (AUTH_IDS_* settings)

Line range hint 1-6: Warning: This is an auto-generated file.

The file header indicates that manual edits should not be made directly. Instead, use the yarn charts command to regenerate the file.

Run this script to check if the changes are consistent across all environments:

@oddsson oddsson enabled auto-merge January 21, 2025 11:02
Copy link
Member

@robertaandersen robertaandersen left a comment

Choose a reason for hiding this comment

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

LGTM

@oddsson oddsson added this pull request to the merge queue Jan 21, 2025
Merged via the queue into main with commit 4f2c7ea Jan 21, 2025
271 checks passed
@oddsson oddsson deleted the j-s/defender-path branch January 21, 2025 13:51
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.

4 participants