Skip to content

refactor: replace MongoDB migration with billing API integration for …#859

Open
Husainbw786 wants to merge 1 commit intotestingfrom
lago_dev_migration
Open

refactor: replace MongoDB migration with billing API integration for …#859
Husainbw786 wants to merge 1 commit intotestingfrom
lago_dev_migration

Conversation

@Husainbw786
Copy link
Copy Markdown
Collaborator

…customer creation and subscription assignment

…customer creation and subscription assignment
Copy link
Copy Markdown
Contributor

@windsurf-bot windsurf-bot bot left a comment

Choose a reason for hiding this comment

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

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";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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`, {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment on lines +74 to 78
} catch (error) {
failed++;
const msg = error.response?.data?.message || error.response?.data || error.message;
console.error(`[${orgId}] Failed: ${JSON.stringify(msg)}\n`);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

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