@faasjs/request 4.7.2 → 5.0.0-beta.2

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.
Files changed (2) hide show
  1. package/package.json +6 -5
  2. package/dist/index.d.mts +0 -134
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@faasjs/request",
3
- "version": "4.7.2",
3
+ "version": "5.0.0-beta.2",
4
4
  "license": "MIT",
5
+ "type": "module",
5
6
  "main": "dist/index.js",
6
7
  "module": "dist/index.mjs",
7
8
  "types": "dist/index.d.ts",
8
9
  "exports": {
9
10
  ".": {
10
11
  "import": {
11
- "types": "./dist/index.d.mts",
12
+ "types": "./dist/index.d.ts",
12
13
  "default": "./dist/index.mjs"
13
14
  },
14
15
  "require": {
@@ -28,16 +29,16 @@
28
29
  },
29
30
  "funding": "https://github.com/sponsors/faasjs",
30
31
  "scripts": {
31
- "build": "tsup-node src/index.ts --config ../../tsup.config.json"
32
+ "build": "tsup-node src/index.ts --config ../../tsup.config.ts"
32
33
  },
33
34
  "files": [
34
35
  "dist"
35
36
  ],
36
37
  "peerDependencies": {
37
- "@faasjs/logger": "4.7.2"
38
+ "@faasjs/logger": "5.0.0-beta.2"
38
39
  },
39
40
  "devDependencies": {
40
- "@faasjs/logger": "4.7.2"
41
+ "@faasjs/logger": "5.0.0-beta.2"
41
42
  },
42
43
  "engines": {
43
44
  "node": ">=22.0.0",
package/dist/index.d.mts DELETED
@@ -1,134 +0,0 @@
1
- import { OutgoingHttpHeaders } from 'node:http';
2
- import https from 'node:https';
3
- import { Logger } from '@faasjs/logger';
4
-
5
- /**
6
- * FaasJS's request module.
7
- *
8
- * [![License: MIT](https://img.shields.io/npm/l/@faasjs/request.svg)](https://github.com/faasjs/faasjs/blob/main/packages/request/LICENSE)
9
- * [![NPM Version](https://img.shields.io/npm/v/@faasjs/request.svg)](https://www.npmjs.com/package/@faasjs/request)
10
- *
11
- * ## Install
12
- *
13
- * ```sh
14
- * npm install @faasjs/request
15
- * ```
16
- * @packageDocumentation
17
- */
18
-
19
- type Request = {
20
- headers?: OutgoingHttpHeaders;
21
- method?: string;
22
- host?: string;
23
- path?: string;
24
- query?: OutgoingHttpHeaders;
25
- body?: {
26
- [key: string]: any;
27
- };
28
- };
29
- type Response<T = any> = {
30
- request?: Request;
31
- statusCode?: number;
32
- statusMessage?: string;
33
- headers: OutgoingHttpHeaders;
34
- body: T;
35
- };
36
- type RequestOptions = {
37
- headers?: OutgoingHttpHeaders;
38
- /**
39
- * The HTTP method to use when making the request. Defaults to GET.
40
- */
41
- method?: string;
42
- query?: {
43
- [key: string]: any;
44
- };
45
- body?: {
46
- [key: string]: any;
47
- } | string;
48
- /** Timeout in milliseconds, @default 5000 */
49
- timeout?: number;
50
- /**
51
- * The authentication credentials to use for the request.
52
- *
53
- * Format: `username:password`
54
- */
55
- auth?: string;
56
- /**
57
- * Path of uploading a file to the server.
58
- *
59
- * ```ts
60
- * await request('https://example.com', { file: 'filepath' })
61
- * ```
62
- */
63
- file?: string;
64
- /**
65
- * Create a write stream to download a file.
66
- *
67
- * ```ts
68
- * import { createWriteStream } from 'fs'
69
- *
70
- * const stream = createWriteStream('filepath')
71
- * await request('https://example.com', { downloadStream: stream })
72
- * ```
73
- */
74
- downloadStream?: NodeJS.WritableStream;
75
- /**
76
- * Path of downloading a file from the server.
77
- *
78
- * ```ts
79
- * await request('https://example.com', { downloadFile: 'filepath' })
80
- * ```
81
- */
82
- downloadFile?: string;
83
- /**
84
- * Body parser. Defaults to `JSON.parse`.
85
- */
86
- parse?: (body: string) => any;
87
- logger?: Logger;
88
- } & Pick<https.RequestOptions, 'pfx' | 'passphrase' | 'agent'>;
89
- type Mock = (url: string, options: RequestOptions) => Promise<Response>;
90
- /**
91
- * Mock requests
92
- * @param handler {function | null} null to disable mock
93
- * @example setMock(async (url, options) => Promise.resolve({ headers: {}, statusCode: 200, body: { data: 'ok' } }))
94
- */
95
- declare function setMock(handler: Mock | null): void;
96
- declare function querystringify(obj: any): string;
97
- /**
98
- * ResponseError class
99
- */
100
- declare class ResponseError extends Error {
101
- response: Response;
102
- request: Request;
103
- statusCode: number;
104
- statusMessage: string;
105
- headers: OutgoingHttpHeaders;
106
- body: any;
107
- constructor(message: string, response: Response<any>);
108
- }
109
- /**
110
- * Request
111
- *
112
- * @param {string} url Url
113
- * @param {object=} [options={}] Options
114
- * @param {string} [options.method=GET] Method
115
- * @param {object} [options.query={}] Query
116
- * @param {object} [options.headers={}] Headers
117
- * @param {object=} options.body Body
118
- * @param {number=} options.timeout Timeout
119
- * @param {string=} options.auth Auth, format: user:password
120
- * @param {string=} options.file Upload file path
121
- * @param {WritableStream=} options.downloadStream Download stream
122
- * @param {string=} options.downloadFile Download to file
123
- * @param {Buffer=} options.pfx pfx
124
- * @param {string=} options.passphrase passphrase
125
- * @param {boolean=} options.agent agent
126
- * @param {parse=} options.parse body parser, default is JSON.parse
127
- *
128
- * @returns {promise}
129
- *
130
- * @url https://faasjs.com/doc/request.html
131
- */
132
- declare function request<T = any>(url: string, options?: RequestOptions): Promise<Response<T>>;
133
-
134
- export { type Request, type RequestOptions, type Response, ResponseError, querystringify, request, setMock };