-
Notifications
You must be signed in to change notification settings - Fork 0
/
constants.ts
49 lines (43 loc) · 1.19 KB
/
constants.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { Status } from '@tshttp/status'
import { CommercetoolsRetryConfig } from './api/index.js'
/**
* Prefixed in the `User-Agent` header before the system identifier (if provided)
*/
export const USER_AGENT_PREFIX = '@gradientedge/commercetools-utils'
/**
* The standard request timeout value (in milliseconds). We pass
* this to `axios` when making the request to commercetools.
*/
export const DEFAULT_REQUEST_TIMEOUT_MS = 5000
/**
* The maximum number of items that can be returned in a query
*/
export const MAX_ITEMS_PER_QUERY = 500
/**
* Sane defaults for retry configuration
*/
export const DEFAULT_RETRY_CONFIG: CommercetoolsRetryConfig = {
maxRetries: 3,
delayMs: 50,
jitter: true,
}
/**
* List of status codes which are allowed to retry
*/
export const RETRYABLE_STATUS_CODES: number[] = [
Status.InternalServerError,
Status.NotImplemented,
Status.BadGateway,
Status.ServiceUnavailable,
Status.GatewayTimeout,
]
/**
* The config options passed in to the {@see HttpsAgent.Agent} used
* with the axios instance that we create.
*/
export const DEFAULT_HTTPS_AGENT_CONFIG = {
keepAlive: true,
maxSockets: 32,
maxFreeSockets: 10,
timeout: DEFAULT_REQUEST_TIMEOUT_MS,
}