Skip to content

Commit cf413a0

Browse files
Refactor effectiveRevenueMonths calculation in qboConfig
- Updated the calculation of effectiveRevenueMonths in the qboConfig to ensure it handles non-finite values correctly. The new implementation uses a self-invoking function to parse the environment variable and defaults to 4 if the value is not a valid number. This change improves the robustness of the configuration by preventing potential errors from invalid input.
1 parent fe3b6c9 commit cf413a0

File tree

1 file changed

+5
-3
lines changed
  • workers/main/src/configs

1 file changed

+5
-3
lines changed

workers/main/src/configs/qbo.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ export const qboConfig = {
1111
tokenHost: 'https://oauth.platform.intuit.com',
1212
tokenPath: '/oauth2/v1/tokens/bearer',
1313
tokenExpirationWindowSeconds: 300,
14-
effectiveRevenueMonths: parseInt(
15-
process.env.QBO_EFFECTIVE_REVENUE_MONTHS || '4',
16-
),
14+
effectiveRevenueMonths: (() => {
15+
const raw = Number(process.env.QBO_EFFECTIVE_REVENUE_MONTHS);
16+
17+
return Number.isFinite(raw) ? Math.trunc(raw) : 4;
18+
})(),
1719
};
1820

1921
export const qboSchema = z.object({

0 commit comments

Comments
 (0)