@faasjs/request 1.4.1 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,164 +1,28 @@
1
1
  # @faasjs/request
2
2
 
3
- [![License: MIT](https://img.shields.io/npm/l/@faasjs/request.svg)](https://github.com/faasjs/faasjs/blob/main/packages/faasjs/request/LICENSE)
4
- [![NPM Stable Version](https://img.shields.io/npm/v/@faasjs/request/stable.svg)](https://www.npmjs.com/package/@faasjs/request)
5
- [![NPM Beta Version](https://img.shields.io/npm/v/@faasjs/request/beta.svg)](https://www.npmjs.com/package/@faasjs/request)
6
-
7
3
  FaasJS's request module.
8
4
 
5
+ [![License: MIT](https://img.shields.io/npm/l/@faasjs/request.svg)](https://github.com/faasjs/faasjs/blob/main/packages/faasjs/request/LICENSE)
6
+ [![NPM Version](https://img.shields.io/npm/v/@faasjs/request.svg)](https://www.npmjs.com/package/@faasjs/request)
7
+
9
8
  ## Install
10
9
 
11
10
  ```sh
12
11
  npm install @faasjs/request
13
12
  ```
14
13
 
15
- ## Modules
16
-
17
- ### Classes
14
+ ## Classes
18
15
 
19
16
  - [ResponseError](classes/ResponseError.md)
20
17
 
21
- ### Type Aliases
22
-
23
- - [Request](#request)
24
- - [RequestOptions](#requestoptions)
25
- - [Response](#response)
26
-
27
- ### Functions
28
-
29
- - [querystringify](#querystringify)
30
- - [request](#request-1)
31
- - [setMock](#setmock)
32
-
33
18
  ## Type Aliases
34
19
 
35
- ### Request
36
-
37
- Ƭ **Request**: `Object`
38
-
39
- #### Type declaration
40
-
41
- | Name | Type |
42
- | :------ | :------ |
43
- | `body?` | \{ `[key: string]`: `any`; } |
44
- | `headers?` | `http.OutgoingHttpHeaders` |
45
- | `host?` | `string` |
46
- | `method?` | `string` |
47
- | `path?` | `string` |
48
- | `query?` | `http.OutgoingHttpHeaders` |
49
-
50
- ___
51
-
52
- ### RequestOptions
53
-
54
- Ƭ **RequestOptions**: `Object`
55
-
56
- #### Type declaration
57
-
58
- | Name | Type | Description |
59
- | :------ | :------ | :------ |
60
- | `agent?` | `boolean` | - |
61
- | `auth?` | `string` | The authentication credentials to use for the request. Format: `username:password` |
62
- | `body?` | \{ `[key: string]`: `any`; } \| `string` | - |
63
- | `downloadFile?` | `string` | Path of downloading a file from the server. ```ts await request('https://example.com', { downloadFile: 'filepath' }) ``` |
64
- | `downloadStream?` | `NodeJS.WritableStream` | Create a write stream to download a file. ```ts import { createWriteStream } from 'fs' const stream = createWriteStream('filepath') await request('https://example.com', { downloadStream: stream }) ``` |
65
- | `file?` | `string` | Path of uploading a file to the server. ```ts await request('https://example.com', { file: 'filepath' }) ``` |
66
- | `headers?` | `http.OutgoingHttpHeaders` | - |
67
- | `logger?` | `Logger` | - |
68
- | `method?` | `string` | The HTTP method to use when making the request. Defaults to GET. |
69
- | `parse?` | (`body`: `string`) => `any` | Body parser. Defaults to `JSON.parse`. |
70
- | `passphrase?` | `string` | - |
71
- | `pfx?` | `Buffer` | - |
72
- | `query?` | \{ `[key: string]`: `any`; } | - |
73
- | `timeout?` | `number` | Timeout in milliseconds, **`Default`** ```ts 5000 ``` |
74
-
75
- ___
76
-
77
- ### Response
78
-
79
- Ƭ **Response**\<`T`\>: `Object`
80
-
81
- #### Type parameters
82
-
83
- | Name | Type |
84
- | :------ | :------ |
85
- | `T` | `any` |
86
-
87
- #### Type declaration
88
-
89
- | Name | Type |
90
- | :------ | :------ |
91
- | `body` | `T` |
92
- | `headers` | `http.OutgoingHttpHeaders` |
93
- | `request?` | [`Request`](#request) |
94
- | `statusCode?` | `number` |
95
- | `statusMessage?` | `string` |
20
+ - [Request](type-aliases/Request.md)
21
+ - [RequestOptions](type-aliases/RequestOptions.md)
22
+ - [Response](type-aliases/Response.md)
96
23
 
97
24
  ## Functions
98
25
 
99
- ### querystringify
100
-
101
- **querystringify**(`obj`): `string`
102
-
103
- #### Parameters
104
-
105
- | Name | Type |
106
- | :------ | :------ |
107
- | `obj` | `any` |
108
-
109
- #### Returns
110
-
111
- `string`
112
-
113
- ___
114
-
115
- ### request
116
-
117
- ▸ **request**\<`T`\>(`url`, `options?`): `Promise`\<[`Response`](#response)\<`T`\>\>
118
-
119
- Request
120
-
121
- #### Type parameters
122
-
123
- | Name | Type |
124
- | :------ | :------ |
125
- | `T` | `any` |
126
-
127
- #### Parameters
128
-
129
- | Name | Type | Description |
130
- | :------ | :------ | :------ |
131
- | `url` | `string` | Url |
132
- | `options?` | [`RequestOptions`](#requestoptions) | Options |
133
-
134
- #### Returns
135
-
136
- `Promise`\<[`Response`](#response)\<`T`\>\>
137
-
138
- **`Url`**
139
-
140
- https://faasjs.com/doc/request.html
141
-
142
- ___
143
-
144
- ### setMock
145
-
146
- ▸ **setMock**(`handler`): `void`
147
-
148
- Mock requests
149
-
150
- #### Parameters
151
-
152
- | Name | Type | Description |
153
- | :------ | :------ | :------ |
154
- | `handler` | `Mock` | {function \| null} null to disable mock |
155
-
156
- #### Returns
157
-
158
- `void`
159
-
160
- **`Example`**
161
-
162
- ```ts
163
- setMock(async (url, options) => Promise.resolve({ headers: {}, statusCode: 200, body: { data: 'ok' } }))
164
- ```
26
+ - [querystringify](functions/querystringify.md)
27
+ - [request](functions/request.md)
28
+ - [setMock](functions/setMock.md)
package/dist/index.d.mts CHANGED
@@ -1,6 +1,20 @@
1
1
  import http from 'node:http';
2
2
  import { Logger } from '@faasjs/logger';
3
3
 
4
+ /**
5
+ * FaasJS's request module.
6
+ *
7
+ * [![License: MIT](https://img.shields.io/npm/l/@faasjs/request.svg)](https://github.com/faasjs/faasjs/blob/main/packages/faasjs/request/LICENSE)
8
+ * [![NPM Version](https://img.shields.io/npm/v/@faasjs/request.svg)](https://www.npmjs.com/package/@faasjs/request)
9
+ *
10
+ * ## Install
11
+ *
12
+ * ```sh
13
+ * npm install @faasjs/request
14
+ * ```
15
+ * @packageDocumentation
16
+ */
17
+
4
18
  type Request = {
5
19
  headers?: http.OutgoingHttpHeaders;
6
20
  method?: string;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,20 @@
1
1
  import http from 'node:http';
2
2
  import { Logger } from '@faasjs/logger';
3
3
 
4
+ /**
5
+ * FaasJS's request module.
6
+ *
7
+ * [![License: MIT](https://img.shields.io/npm/l/@faasjs/request.svg)](https://github.com/faasjs/faasjs/blob/main/packages/faasjs/request/LICENSE)
8
+ * [![NPM Version](https://img.shields.io/npm/v/@faasjs/request.svg)](https://www.npmjs.com/package/@faasjs/request)
9
+ *
10
+ * ## Install
11
+ *
12
+ * ```sh
13
+ * npm install @faasjs/request
14
+ * ```
15
+ * @packageDocumentation
16
+ */
17
+
4
18
  type Request = {
5
19
  headers?: http.OutgoingHttpHeaders;
6
20
  method?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/request",
3
- "version": "1.4.1",
3
+ "version": "1.5.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -21,10 +21,10 @@
21
21
  "dist"
22
22
  ],
23
23
  "peerDependencies": {
24
- "@faasjs/logger": "1.4.1"
24
+ "@faasjs/logger": "1.5.0"
25
25
  },
26
26
  "devDependencies": {
27
- "@faasjs/logger": "1.4.1"
27
+ "@faasjs/logger": "1.5.0"
28
28
  },
29
29
  "engines": {
30
30
  "npm": ">=9.0.0",