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