-
Notifications
You must be signed in to change notification settings - Fork 0
added custom prediction backend url #58
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
base: staging
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
📝 WalkthroughWalkthroughThe changes introduce a new constant Changes
Poem
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 (1)
frontend/src/services/apiService.tsx (1)
Line range hint
1-100
: Consider restructuring the API services architectureAs the API services grow in complexity, consider:
- Moving interfaces to a separate
types.ts
file- Creating separate files for different API services (e.g.,
predictionApiService.ts
,satelliteApiService.ts
)- Creating a common configuration file for shared axios settings
This would improve maintainability and make the codebase more modular.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
frontend/package-lock.json
is excluded by!**/package-lock.json
📒 Files selected for processing (1)
frontend/src/services/apiService.tsx
(2 hunks)
const predictionApiService = axios.create({ | ||
baseURL: removeTrailingSlash(PREDICTION_API_URL), | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add missing API configuration and consider DRY principle
The new prediction service is missing several important configurations that exist in the usage of the main apiService:
- API token authentication
- Request timeout
- Error handling interceptors
Also, consider extracting common axios configurations to avoid duplication.
+const commonAxiosConfig = {
+ headers: {
+ "Content-Type": "application/json",
+ },
+ timeout: 30000, // Add reasonable timeout
+};
-const predictionApiService = axios.create({
- baseURL: removeTrailingSlash(PREDICTION_API_URL),
- headers: {
- "Content-Type": "application/json",
- },
-});
+const predictionApiService = axios.create({
+ ...commonAxiosConfig,
+ baseURL: removeTrailingSlash(PREDICTION_API_URL),
+});
+// Add error interceptor
+predictionApiService.interceptors.response.use(
+ response => response,
+ error => {
+ console.error('Prediction API Error:', error);
+ return Promise.reject(error);
+ }
+);
Committable suggestion skipped: line range outside the PR's diff.
💡 Codebase verification
New prediction service created but not utilized yet
The predictionApiService
appears to be a new addition while the existing satellite prediction endpoint still uses the original apiService
. This suggests incomplete implementation, as the new service isn't being used yet. Consider either:
- Using the new
predictionApiService
for the satellite prediction endpoint - Adding a comment explaining the intended future use of this service
- Removing it if it's no longer needed
🔗 Analysis chain
Verify implementation status of the prediction service
The new predictionApiService
is created but not utilized in any of the existing functions. Is this intentional or are there pending implementations?
The previous command failed because the tsx
file type wasn't recognized. Let's try with just TypeScript files and also specifically look for prediction-related functionality to understand the context better.
Let's dig deeper to understand if there are any existing prediction-related functions or types that might be intended to use this new service.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for any usage of predictionApiService in the codebase
rg "predictionApiService" --type ts --type tsx
Length of output: 74
Script:
#!/bin/bash
# Search for any usage of predictionApiService in TypeScript files
rg "predictionApiService" -t ts
# Also search in the specific file to verify the service definition
rg "predictionApiService" frontend/src/services/apiService.tsx || echo "File not found"
# Let's check for any prediction-related API calls that might be using this service
rg "prediction" -t ts -g "!*.test.*" -g "!*.spec.*"
Length of output: 928
Script:
#!/bin/bash
# Let's check the satellite prediction endpoint usage
rg "satellite_prediction" -A 5 -B 5 frontend/src/services/apiService.tsx
# Check for any prediction-related types or interfaces
ast-grep --pattern 'interface $_ {
$$$
prediction
$$$
}'
# Look for any prediction-related functions
ast-grep --pattern 'function $_($$_) {
$$$
prediction
$$$
}'
Length of output: 486
@@ -3,6 +3,7 @@ import axios from "axios"; | |||
|
|||
const apiToken = process.env.NEXT_PUBLIC_API_TOKEN; | |||
const BASE_URL = process.env.NEXT_PUBLIC_API_URL || ""; | |||
const PREDICTION_API_URL = process.env.NEXT_PUBLIC_API_URL_DIGITAL_OCEAN || ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider adding URL validation and proper error handling
The fallback to an empty string could lead to silent failures. Consider:
- Adding runtime validation for the URL
- Using a more descriptive environment variable name (e.g.,
NEXT_PUBLIC_PREDICTION_API_URL
) - Adding proper error handling for missing configuration
-const PREDICTION_API_URL = process.env.NEXT_PUBLIC_API_URL_DIGITAL_OCEAN || '';
+const PREDICTION_API_URL = process.env.NEXT_PUBLIC_PREDICTION_API_URL;
+if (!PREDICTION_API_URL) {
+ console.error('Prediction API URL is not configured');
+}
Committable suggestion skipped: line range outside the PR's diff.
Summary by CodeRabbit
New Features
Bug Fixes