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

(DAL) Simplify api endpoint #1865

Merged
merged 3 commits into from
Jul 22, 2024
Merged

(DAL) Simplify api endpoint #1865

merged 3 commits into from
Jul 22, 2024

Conversation

nick-bisonai
Copy link
Collaborator

@nick-bisonai nick-bisonai commented Jul 20, 2024

Description

simplify endpoint before official launch

  • AS IS
    https://dal.baobab.orakl.network/api/v1/dal/symbols

  • TO BE
    https://dal.baobab.orakl.network/symbols

the healthcheck endpoints should also be updated from helmchart yaml files

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist before requesting a review

  • I have performed a self-review of my code.
  • If it is a core feature, I have added thorough tests.

Deployment

  • Should publish npm package
  • Should publish Docker image

@nick-bisonai nick-bisonai self-assigned this Jul 20, 2024
@nick-bisonai nick-bisonai requested a review from a team as a code owner July 20, 2024 10:06
Copy link
Contributor

coderabbitai bot commented Jul 20, 2024

Walkthrough

Walkthrough

The changes involve a significant restructuring of API endpoint paths by removing versioning prefixes across various files in the project. This simplification allows direct access to endpoints without needing to include versioning in the URL, potentially enhancing usability for clients and streamlining the API's routing logic.

Changes

File(s) Change Summary
node/pkg/dal/api/route.go Removed the "/dal" prefix from route groups, allowing direct access to /symbols and /latest-data-feeds/all.
node/pkg/dal/app.go Altered endpoint grouping from "/api/v1" to "", making the API accessible directly at the root level.
node/pkg/dal/tests/api_test.go Updated test endpoints from "/api/v1/dal" to simplified paths, aligning with the new routing structure.
node/pkg/dal/tests/collector_test.go Changed WebSocket endpoint in tests from "/api/v1/dal/ws" to "/ws", reflecting the new path structure.
node/pkg/dal/tests/main_test.go Modified the base path for API tests from "/api/v1" to "", removing versioning from test setup.
node/pkg/dal/utils/initializer/initializer.go Updated the authFilter to check against "/" instead of "/api/v1", broadening access control.
node/pkg/dal/utils/stats/stats.go Altered StatsMiddleware condition from "/api/v1" to "/", changing how statistics are processed for root requests.

Poem

🐰 In a world of paths so wide and new,
Our routes now dance, a simpler view.
From prefixes gone, we hop with glee,
Just one small step, so wild and free!
Hooray for change, let’s cheer and play,
The endpoints bloom in a bright array! 🌼


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

@nick-bisonai nick-bisonai linked an issue Jul 20, 2024 that may be closed by this pull request
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

Outside diff range, codebase verification and nitpick comments (1)
node/pkg/dal/tests/main_test.go (1)

115-115: Update Route Definitions to Match the New Base Path

The base path for the API group has been updated to remove versioning. However, several files still use the old base path (/api/v1). Please update the following files to use the new base path (""):

  • node/pkg/admin/tests/main_test.go
  • node/pkg/boot/tests/main_test.go
  • node/pkg/boot/boot.go
  • node/pkg/admin/admin.go
  • delegator/main.go
  • api/tests/apierr_test.go
  • api/tests/proxy_test.go
  • api/tests/reporter_test.go
  • api/tests/listener_test.go
  • api/tests/chain_test.go
  • api/main.go
  • api/tests/vrf_test.go
  • api/tests/service_test.go

Please ensure that all route definitions in these files are updated to match the new base path.

Analysis chain

LGTM! But verify the route definitions.

The base path for the API group has been updated to remove versioning, simplifying the endpoint structure.

However, ensure that all route definitions in the codebase are updated to match the new structure.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all route definitions use the updated base path.

# Test: Search for route definitions. Expect: Only occurrences of the new base path.
rg --type go -A 5 $'app.Group'

Length of output: 4404

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 75700a8 and bf57095.

Files ignored due to path filters (2)
  • sentinel/pkg/checker/health/baobab_healthcheck.json is excluded by !**/*.json
  • sentinel/pkg/checker/health/cypress_healthcheck.json is excluded by !**/*.json
Files selected for processing (7)
  • node/pkg/dal/api/route.go (1 hunks)
  • node/pkg/dal/app.go (1 hunks)
  • node/pkg/dal/tests/api_test.go (4 hunks)
  • node/pkg/dal/tests/collector_test.go (1 hunks)
  • node/pkg/dal/tests/main_test.go (1 hunks)
  • node/pkg/dal/utils/initializer/initializer.go (1 hunks)
  • node/pkg/dal/utils/stats/stats.go (1 hunks)
Additional comments not posted (9)
node/pkg/dal/api/route.go (1)

9-9: Ensure route grouping change does not break existing functionality.

The route grouping has been changed from "/dal" to "", which means routes are now directly accessible. Verify that this change does not break any existing functionality or client integrations.

node/pkg/dal/app.go (1)

43-43: Ensure route grouping change does not break existing functionality.

The route grouping has been changed from "/api/v1" to "", which means routes are now directly accessible. Verify that this change does not break any existing functionality or client integrations.

node/pkg/dal/utils/stats/stats.go (1)

81-81: Ensure condition change does not affect statistics gathering.

The condition for bypassing further processing has been changed from "/api/v1" to "/". Verify that this change does not affect the gathering of statistics for other endpoints.

node/pkg/dal/tests/collector_test.go (1)

59-59: LGTM! But verify the WebSocket endpoint usage.

The WebSocket endpoint URL has been updated to match the new simplified structure.

However, ensure that all WebSocket connections in the codebase use the updated endpoint.

Verification successful

WebSocket endpoint usage verified.

The WebSocket connections in the codebase use service-specific endpoints, and the test files correctly use the updated endpoint ws://localhost:8090/ws.

  • node/pkg/dal/tests/collector_test.go
  • node/pkg/dal/tests/api_test.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all WebSocket connections use the updated endpoint.

# Test: Search for WebSocket connections. Expect: Only occurrences of the new endpoint.
rg --type go -A 5 $'wss.NewWebsocketHelper'

Length of output: 13995


Script:

#!/bin/bash
# Description: Search for the definition or assignment of the URL variable to verify it uses the updated endpoint.

# Test: Search for the definition or assignment of the URL variable.
rg --type go 'URL\s*[:=]'

Length of output: 3118

node/pkg/dal/utils/initializer/initializer.go (1)

130-130: LGTM! But verify the authentication logic.

The authFilter function has been updated to check the root URL, aligning with the new endpoint structure.

However, ensure that the authentication logic throughout the codebase is updated to match this change and does not introduce security issues.

Verification successful

Authentication logic verification complete.

The authFilter function's logic is correctly updated to check the root URL, and there are no conflicting authentication mechanisms in the codebase.

  • authFilter function is only used in node/pkg/dal/utils/initializer/initializer.go and correctly checks the root URL.
  • Other authentication mechanisms found are unrelated to this specific change.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the authentication logic matches the updated endpoint structure.

# Test: Search for authentication logic. Expect: Only occurrences of the new root URL.
rg --type go -A 5 $'authFilter'

Length of output: 876


Script:

#!/bin/bash
# Description: Verify the authentication logic throughout the codebase to match the updated endpoint structure.

# Search for other instances of authentication logic across the codebase.
rg --type go -A 5 'auth|authentication|authFilter|validator'

Length of output: 26486

node/pkg/dal/tests/api_test.go (4)

64-64: LGTM! Endpoint URL updated correctly.

The endpoint URL has been updated to http://localhost:8090/latest-data-feeds/all as per the new structure. This change is consistent with the PR objectives.


92-92: LGTM! Endpoint URLs updated correctly.

The endpoint URLs have been updated to http://localhost:8090/ and http://localhost:8090/latest-data-feeds/test-aggregate as per the new structure. These changes are consistent with the PR objectives.

Also applies to: 99-99


139-139: LGTM! Endpoint URL updated correctly.

The endpoint URL has been updated to http://localhost:8090/latest-data-feeds/test-aggregate as per the new structure. This change is consistent with the PR objectives.


166-166: LGTM! Endpoint URL updated correctly.

The endpoint URL has been updated to ws://localhost:8090/ws as per the new structure. This change is consistent with the PR objectives.

Copy link
Contributor

@Intizar-T Intizar-T left a comment

Choose a reason for hiding this comment

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

lgtm!

@nick-bisonai nick-bisonai merged commit 98e63ea into master Jul 22, 2024
2 checks passed
@nick-bisonai nick-bisonai deleted the feat/simplify-api-endpoint branch July 22, 2024 01:42
@coderabbitai coderabbitai bot mentioned this pull request Jan 20, 2025
8 tasks
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.

(DAL) simplify endpoint
2 participants