@faasjs/request 0.0.3-beta.4 → 0.0.3-beta.40

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
@@ -52,10 +52,10 @@ ___
52
52
  | Name | Type | Description |
53
53
  | :------ | :------ | :------ |
54
54
  | `agent?` | `boolean` | - |
55
- | `auth?` | `string` | The authentication credentials to use for the request. Format: `username:password` |
55
+ | `auth?` | `string` | The authentication credentials to use for the request. Format: `username:password` |
56
56
  | `body?` | { `[key: string]`: `any`; } \| `string` | - |
57
- | `downloadStream?` | `NodeJS.WritableStream` | Create a write stream to download a file. |
58
- | `file?` | `string` | Path of uploading a file to the server. |
57
+ | `downloadStream?` | `NodeJS.WritableStream` | Create a write stream to download a file. ```ts const stream = createWriteStream('filepath') await request('https://example.com', { downloadStream: stream }) ``` |
58
+ | `file?` | `string` | Path of uploading a file to the server. ```ts await request('https://example.com', { file: 'filepath' }) ``` |
59
59
  | `headers?` | `http.OutgoingHttpHeaders` | - |
60
60
  | `logger?` | `Logger` | - |
61
61
  | `method?` | `string` | The HTTP method to use when making the request. Defaults to GET. |
package/dist/index.d.ts CHANGED
@@ -39,10 +39,19 @@ type RequestOptions = {
39
39
  auth?: string;
40
40
  /**
41
41
  * Path of uploading a file to the server.
42
+ *
43
+ * ```ts
44
+ * await request('https://example.com', { file: 'filepath' })
45
+ * ```
42
46
  */
43
47
  file?: string;
44
48
  /**
45
49
  * Create a write stream to download a file.
50
+ *
51
+ * ```ts
52
+ * const stream = createWriteStream('filepath')
53
+ * await request('https://example.com', { downloadStream: stream })
54
+ * ```
46
55
  */
47
56
  downloadStream?: NodeJS.WritableStream;
48
57
  pfx?: Buffer;
package/dist/index.js CHANGED
@@ -145,7 +145,7 @@ async function request(url, {
145
145
  response.body = data;
146
146
  if (response.body && response.headers["content-type"] && response.headers["content-type"].includes("application/json"))
147
147
  try {
148
- response.body = parse ? parse(response.body) : JSON.parse(response.body);
148
+ response.body = (parse || JSON.parse)(response.body);
149
149
  logger.debug("response.parse JSON");
150
150
  } catch (error) {
151
151
  console.warn("response plain body", response.body);
package/dist/index.mjs CHANGED
@@ -113,7 +113,7 @@ async function request(url, {
113
113
  response.body = data;
114
114
  if (response.body && response.headers["content-type"] && response.headers["content-type"].includes("application/json"))
115
115
  try {
116
- response.body = parse ? parse(response.body) : JSON.parse(response.body);
116
+ response.body = (parse || JSON.parse)(response.body);
117
117
  logger.debug("response.parse JSON");
118
118
  } catch (error) {
119
119
  console.warn("response plain body", response.body);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/request",
3
- "version": "0.0.3-beta.4",
3
+ "version": "0.0.3-beta.40",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -22,7 +22,7 @@
22
22
  "dist"
23
23
  ],
24
24
  "dependencies": {
25
- "@faasjs/logger": "^0.0.3-beta.4"
25
+ "@faasjs/logger": "^0.0.3-beta.40"
26
26
  },
27
27
  "engines": {
28
28
  "npm": ">=8.0.0",