Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions workers/main/src/configs/axios.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { describe, expect, it } from 'vitest';

import { axiosConfig } from './axios';

describe('axiosConfig', () => {
it('should have required properties', () => {
expect(axiosConfig).toHaveProperty('timeout');
expect(axiosConfig).toHaveProperty('maxRetries');
expect(axiosConfig).toHaveProperty('headers');
});

it('should have correct timeout value', () => {
expect(axiosConfig.timeout).toBe(30000);
});

it('should have correct maxRetries value', () => {
expect(axiosConfig.maxRetries).toBe(3);
});

it('should have correct headers', () => {
expect(axiosConfig.headers).toEqual({
'Content-Type': 'application/json',
'Accept': 'application/json',
});
});

it('should have Content-Type header', () => {
expect(axiosConfig.headers['Content-Type']).toBe('application/json');
});

it('should have Accept header', () => {
expect(axiosConfig.headers['Accept']).toBe('application/json');
});
});
8 changes: 8 additions & 0 deletions workers/main/src/configs/axios.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const axiosConfig = {
timeout: 30000,
maxRetries: 3,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
};
13 changes: 9 additions & 4 deletions workers/main/src/configs/qbo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,20 @@ export const qboConfig = {
clientSecret: process.env.QBO_CLIENT_SECRET,
companyId: process.env.QBO_COMPANY_ID,
refreshToken: process.env.QBO_REFRESH_TOKEN,
tokenEndpoint:
process.env.QBO_TOKEN_ENDPOINT ||
'https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer',
tokenHost: 'https://oauth.platform.intuit.com',
tokenPath: '/oauth2/v1/tokens/bearer',
tokenExpirationWindowSeconds: 300,
effectiveRevenueMonths: parseInt(
process.env.QBO_EFFECTIVE_REVENUE_MONTHS || '3',
),
Comment thread
killev marked this conversation as resolved.
};

export const qboSchema = z.object({
QBO_API_URL: z.string().url().min(1, 'QBO_API_URL is required'),
QBO_BEARER_TOKEN: z.string().optional(),
Comment thread
anatolyshipitz marked this conversation as resolved.
QBO_CLIENT_ID: z.string().min(1, 'QBO_CLIENT_ID is required'),
QBO_CLIENT_SECRET: z.string().min(1, 'QBO_CLIENT_SECRET is required'),
QBO_COMPANY_ID: z.string().min(1, 'QBO_COMPANY_ID is required'),
QBO_REFRESH_TOKEN: z.string().optional(),
QBO_REFRESH_TOKEN: z.string(),
QBO_EFFECTIVE_REVENUE_MONTHS: z.string().optional(),
});