UNPKG

1.46 kBTypeScriptView Raw
1import { AnyObject, CommonLogger } from '@naturalcycles/js-lib';
2import type { Options } from 'got';
3export interface GetGotOptions extends Options {
4 /**
5 * Set to `true` to enable all possible debug logging.
6 * Not safe in prod (as it logs Responses), but great to use during development.
7 */
8 debug?: boolean;
9 /**
10 * @default false
11 */
12 logStart?: boolean;
13 /**
14 * Log when request is finished.
15 *
16 * @default false
17 */
18 logFinished?: boolean;
19 /**
20 * Log request object.
21 *
22 * @default false
23 */
24 logRequest?: boolean;
25 /**
26 * Log actual response object.
27 *
28 * @default false
29 */
30 logResponse?: boolean;
31 /**
32 * @default true
33 * Set to false to exclude `prefixUrl` from logs (both success and error)
34 */
35 logWithPrefixUrl?: boolean;
36 /**
37 * @default true
38 * Set to false to strip searchParams from url when logging (both success and error)
39 */
40 logWithSearchParams?: boolean;
41 /**
42 * Defaults to `console`
43 */
44 logger?: CommonLogger;
45 /**
46 * Max length of response object before it's truncated.
47 *
48 * @default 10_000
49 */
50 maxResponseLength?: number;
51}
52export interface GotRequestContext extends AnyObject {
53 /**
54 * Millisecond-timestamp of when the request was started. To be able to count "time spent".
55 */
56 started: number;
57 err?: Error;
58 retryCount?: number;
59}