refactor: replace MongoDB migration with billing API integration for …#859
refactor: replace MongoDB migration with billing API integration for …#859Husainbw786 wants to merge 1 commit intotestingfrom
Conversation
…customer creation and subscription assignment
There was a problem hiding this comment.
Other comments (1)
- test.js (80-80) There's a fixed 100ms delay between processing each organization. Consider making this configurable or implementing a more robust rate limiting approach that can adapt to API requirements (e.g., exponential backoff on failures).
💡 To request another review, post a new comment with "/windsurf-review".
| import axios from "axios"; | ||
|
|
||
| const BILLING_API_BASE = "https://api.billing.gtwy.ai/api/v1"; | ||
| const BILLING_AUTH_TOKEN = "Bearer e7f5c7ab-fe9d-4b1e-a4f6-63d333bfe068"; |
There was a problem hiding this comment.
The authentication token is hardcoded in the source code. This is a security risk as it could be exposed in version control. Consider moving this to an environment variable like you've done with PUBLIC_REFERENCEID and ADMIN_API_KEY.
| }; | ||
|
|
||
| async function getAllOrgs() { | ||
| const response = await axios.get(`https://routes.msg91.com/api/${PUBLIC_REFERENCEID}/getCompanies?itemsPerPage=17321`, { |
There was a problem hiding this comment.
The API call to get companies has a hardcoded itemsPerPage=17321 parameter. This seems like an arbitrary number and could lead to incomplete data if the number of organizations grows beyond this limit. Consider implementing proper pagination to handle any number of organizations.
| } catch (error) { | ||
| failed++; | ||
| const msg = error.response?.data?.message || error.response?.data || error.message; | ||
| console.error(`[${orgId}] Failed: ${JSON.stringify(msg)}\n`); | ||
| } |
There was a problem hiding this comment.
The error handling doesn't distinguish between different types of failures (e.g., network issues, validation errors, duplicate entries). Consider adding more detailed error categorization to make troubleshooting easier and potentially handle certain error types differently.
…customer creation and subscription assignment