@andbridge/glowpod 1.0.7 → 1.0.9

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.
@@ -1 +1 @@
1
- import e from"axios";class s{constructor(s){this.getInstance=()=>this.instance,this.Get=e=>this.instance({method:"GET",url:e.url,params:e.params,headers:{...e.headers},...e.others}),this.Put=e=>this.instance({method:"PUT",url:e.url,params:e.params,headers:{...e.headers},...e.others}),this.Delete=e=>this.instance({method:"DELETE",url:e.url,params:e.params,headers:{...e.headers},...e.others}),this.Post=e=>this.instance({method:"POST",url:e.url,data:e.params,headers:{...e.headers},...e.others}),this.instance=e.create(s)}}const t=()=>{},a=()=>{},r=()=>{};var o;!function(e){e[e.success=200]="success"}(o||(o={}));const n=({instance:e,authTokenStorageName:s="token",authFailedCaller:n=t,networkSuccessCode:c=200,authFailedCode:d=401,networkFailedCaller:h=a,serverKillCaller:i=r,responseStruct:l={codeName:"code",messageName:"message",dataName:"data"}})=>{let u=null,m=!0;const p=e=>(u&&clearTimeout(u),u=setTimeout(()=>{m&&(e.status==o.success?(e.data?.[l.codeName]==d&&n(),e.data?.[l.codeName]!=c&&h()):i())},0),()=>m=!1);e.interceptors.request.use(async e=>{const t=localStorage.getItem(s);return t&&e.headers&&e.headers.set(s,t),e},e=>(console.log("请求错误拦截器:",e),p(e),Promise.reject(e))),e.interceptors.response.use(e=>{if("blob"===e.config.responseType)return e;if(e.data?.[l.codeName]===c)return e.data?.[l.dataName];{const s=p(e);throw{...e,hiddenDefaultErrorHandler:s}}},e=>{const s=p(e);throw{...e,hiddenDefaultErrorHandler:s}})};export{s as GlowPod,n as setupInterceptors};
1
+ import e from"axios";class t{constructor(t){this.getInstance=()=>this.instance,this.Get=e=>this.instance({method:"GET",url:e.url,params:e.params,headers:{...e.headers},...e.others}),this.Put=e=>this.instance({method:"PUT",url:e.url,params:e.params,headers:{...e.headers},...e.others}),this.Delete=e=>this.instance({method:"DELETE",url:e.url,params:e.params,headers:{...e.headers},...e.others}),this.Post=e=>this.instance({method:"POST",url:e.url,data:e.params,headers:{...e.headers},...e.others}),this.instance=e.create(t)}}const a=()=>{},s=()=>{},r=()=>{},o=200,n=299,d=({instance:e,authTokenStorageName:t="token",authFailedCaller:d=a,networkSuccessCode:h=200,authFailedCode:i=401,networkFailedCaller:l=s,serverKillCaller:c=r,responseStruct:u={codeName:"code",messageName:"message",dataName:"data"}})=>{let m=null,p=!0;const g=e=>(m&&clearTimeout(m),m=setTimeout(()=>{if(p)return e.status<=o&&e.status>=n?c():e.data?.[u.codeName]==i?d():e.data?.[u.codeName]!=h?l():void 0},0),()=>p=!1);e.interceptors.request.use(async e=>{const a=localStorage.getItem(t);return a&&e.headers&&e.headers.set(t,a),e},e=>(console.log("请求错误拦截器:",e),g(e),Promise.reject(e))),e.interceptors.response.use(e=>{if("blob"===e.config.responseType)return e;if(e.data?.[u.codeName]===h)return e.data?.[u.dataName];{const t=g(e);throw{...e,hiddenDefaultErrorHandler:t}}},e=>{const t=g(e);throw{...e,hiddenDefaultErrorHandler:t}})};export{t as GlowPod,d as setupInterceptors};
package/build/glowpod.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("axios");const s=()=>{},t=()=>{},a=()=>{};var r;!function(e){e[e.success=200]="success"}(r||(r={}));exports.GlowPod=class{constructor(s){this.getInstance=()=>this.instance,this.Get=e=>this.instance({method:"GET",url:e.url,params:e.params,headers:{...e.headers},...e.others}),this.Put=e=>this.instance({method:"PUT",url:e.url,params:e.params,headers:{...e.headers},...e.others}),this.Delete=e=>this.instance({method:"DELETE",url:e.url,params:e.params,headers:{...e.headers},...e.others}),this.Post=e=>this.instance({method:"POST",url:e.url,data:e.params,headers:{...e.headers},...e.others}),this.instance=e.create(s)}},exports.setupInterceptors=({instance:e,authTokenStorageName:o="token",authFailedCaller:n=s,networkSuccessCode:c=200,authFailedCode:d=401,networkFailedCaller:h=t,serverKillCaller:i=a,responseStruct:l={codeName:"code",messageName:"message",dataName:"data"}})=>{let u=null,m=!0;const p=e=>(u&&clearTimeout(u),u=setTimeout(()=>{m&&(e.status==r.success?(e.data?.[l.codeName]==d&&n(),e.data?.[l.codeName]!=c&&h()):i())},0),()=>m=!1);e.interceptors.request.use(async e=>{const s=localStorage.getItem(o);return s&&e.headers&&e.headers.set(o,s),e},e=>(console.log("请求错误拦截器:",e),p(e),Promise.reject(e))),e.interceptors.response.use(e=>{if("blob"===e.config.responseType)return e;if(e.data?.[l.codeName]===c)return e.data?.[l.dataName];{const s=p(e);throw{...e,hiddenDefaultErrorHandler:s}}},e=>{const s=p(e);throw{...e,hiddenDefaultErrorHandler:s}})};
1
+ "use strict";var e=require("axios");const t=()=>{},s=()=>{},a=()=>{},r=200,o=299;exports.GlowPod=class{constructor(t){this.getInstance=()=>this.instance,this.Get=e=>this.instance({method:"GET",url:e.url,params:e.params,headers:{...e.headers},...e.others}),this.Put=e=>this.instance({method:"PUT",url:e.url,params:e.params,headers:{...e.headers},...e.others}),this.Delete=e=>this.instance({method:"DELETE",url:e.url,params:e.params,headers:{...e.headers},...e.others}),this.Post=e=>this.instance({method:"POST",url:e.url,data:e.params,headers:{...e.headers},...e.others}),this.instance=e.create(t)}},exports.setupInterceptors=({instance:e,authTokenStorageName:n="token",authFailedCaller:d=t,networkSuccessCode:i=200,authFailedCode:h=401,networkFailedCaller:c=s,serverKillCaller:l=a,responseStruct:u={codeName:"code",messageName:"message",dataName:"data"}})=>{let m=null,p=!0;const g=e=>(m&&clearTimeout(m),m=setTimeout(()=>{if(p)return e.status<=r&&e.status>=o?l():e.data?.[u.codeName]==h?d():e.data?.[u.codeName]!=i?c():void 0},0),()=>p=!1);e.interceptors.request.use(async e=>{const t=localStorage.getItem(n);return t&&e.headers&&e.headers.set(n,t),e},e=>(console.log("请求错误拦截器:",e),g(e),Promise.reject(e))),e.interceptors.response.use(e=>{if("blob"===e.config.responseType)return e;if(e.data?.[u.codeName]===i)return e.data?.[u.dataName];{const t=g(e);throw{...e,hiddenDefaultErrorHandler:t}}},e=>{const t=g(e);throw{...e,hiddenDefaultErrorHandler:t}})};
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("axios")):"function"==typeof define&&define.amd?define(["exports","axios"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).GlowPod={},e.axios)}(this,function(e,t){"use strict";const s=()=>{},a=()=>{},r=()=>{};var o;!function(e){e[e.success=200]="success"}(o||(o={}));e.GlowPod=class{constructor(e){this.getInstance=()=>this.instance,this.Get=e=>this.instance({method:"GET",url:e.url,params:e.params,headers:{...e.headers},...e.others}),this.Put=e=>this.instance({method:"PUT",url:e.url,params:e.params,headers:{...e.headers},...e.others}),this.Delete=e=>this.instance({method:"DELETE",url:e.url,params:e.params,headers:{...e.headers},...e.others}),this.Post=e=>this.instance({method:"POST",url:e.url,data:e.params,headers:{...e.headers},...e.others}),this.instance=t.create(e)}},e.setupInterceptors=({instance:e,authTokenStorageName:t="token",authFailedCaller:n=s,networkSuccessCode:d=200,authFailedCode:i=401,networkFailedCaller:c=a,serverKillCaller:l=r,responseStruct:u={codeName:"code",messageName:"message",dataName:"data"}})=>{let h=null,m=!0;const p=e=>(h&&clearTimeout(h),h=setTimeout(()=>{m&&(e.status==o.success?(e.data?.[u.codeName]==i&&n(),e.data?.[u.codeName]!=d&&c()):l())},0),()=>m=!1);e.interceptors.request.use(async e=>{const s=localStorage.getItem(t);return s&&e.headers&&e.headers.set(t,s),e},e=>(console.log("请求错误拦截器:",e),p(e),Promise.reject(e))),e.interceptors.response.use(e=>{if("blob"===e.config.responseType)return e;if(e.data?.[u.codeName]===d)return e.data?.[u.dataName];{const t=p(e);throw{...e,hiddenDefaultErrorHandler:t}}},e=>{const t=p(e);throw{...e,hiddenDefaultErrorHandler:t}})}});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("axios")):"function"==typeof define&&define.amd?define(["exports","axios"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).GlowPod={},e.axios)}(this,function(e,t){"use strict";const s=()=>{},a=()=>{},r=()=>{},o=200,n=299;e.GlowPod=class{constructor(e){this.getInstance=()=>this.instance,this.Get=e=>this.instance({method:"GET",url:e.url,params:e.params,headers:{...e.headers},...e.others}),this.Put=e=>this.instance({method:"PUT",url:e.url,params:e.params,headers:{...e.headers},...e.others}),this.Delete=e=>this.instance({method:"DELETE",url:e.url,params:e.params,headers:{...e.headers},...e.others}),this.Post=e=>this.instance({method:"POST",url:e.url,data:e.params,headers:{...e.headers},...e.others}),this.instance=t.create(e)}},e.setupInterceptors=({instance:e,authTokenStorageName:t="token",authFailedCaller:d=s,networkSuccessCode:i=200,authFailedCode:l=401,networkFailedCaller:c=a,serverKillCaller:h=r,responseStruct:u={codeName:"code",messageName:"message",dataName:"data"}})=>{let m=null,p=!0;const f=e=>(m&&clearTimeout(m),m=setTimeout(()=>{if(p)return e.status<=o&&e.status>=n?h():e.data?.[u.codeName]==l?d():e.data?.[u.codeName]!=i?c():void 0},0),()=>p=!1);e.interceptors.request.use(async e=>{const s=localStorage.getItem(t);return s&&e.headers&&e.headers.set(t,s),e},e=>(console.log("请求错误拦截器:",e),f(e),Promise.reject(e))),e.interceptors.response.use(e=>{if("blob"===e.config.responseType)return e;if(e.data?.[u.codeName]===i)return e.data?.[u.dataName];{const t=f(e);throw{...e,hiddenDefaultErrorHandler:t}}},e=>{const t=f(e);throw{...e,hiddenDefaultErrorHandler:t}})}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andbridge/glowpod",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "A axios-based HTTP client library",
5
5
  "main": "build/glowpod.js",
6
6
  "module": "build/glowpod.esm.js",
package/readme.md ADDED
@@ -0,0 +1,344 @@
1
+ ### @andbrigd/glowpod is a network request library base on axios.
2
+
3
+
4
+ # Installation
5
+ pnpm download
6
+ ```bash
7
+ pnpm install @andbrigd/glowpod
8
+ ```
9
+ yarn download
10
+ ```bash
11
+ yarn add @andbrigd/glowpod
12
+ ```
13
+ npm download
14
+ ```bash
15
+ npm install @andbrigd/glowpod
16
+ ```
17
+
18
+ # Usage
19
+ ## base usage
20
+ ```ts
21
+ import { GlowPod } from "@andbridge/glowpod";
22
+
23
+ const glowpod = new GlowPod({
24
+ baseURL: "",
25
+ });
26
+
27
+ glowpod.Get("/api/v1/users").then((res) => {})
28
+
29
+ glowpod.Post("/api/v1/users", {})
30
+
31
+ glowpod.Put("/api/v1/users", {})
32
+
33
+ glowpod.Delete("/api/v1/users", {})
34
+ ```
35
+
36
+ ## custom config
37
+
38
+ ```ts
39
+ import { GlowPod } from "@andbridge/glowpod";
40
+
41
+
42
+
43
+ const glowpod = new GlowPod({
44
+ // `url` is the server URL that will be used for the request
45
+ url: '/user',
46
+ // `method` is the request method to be used when making the request
47
+ method: 'get', // default
48
+ // `baseURL` will be prepended to `url` unless `url` is absolute.
49
+ // It can be convenient to set `baseURL` for an instance of axios to pass relative URLs
50
+ // to methods of that instance.
51
+ baseURL: 'https://some-domain.com/api',
52
+ // `allowAbsoluteUrls` determines whether or not absolute URLs will override a configured `baseUrl`.
53
+ // When set to true (default), absolute values for `url` will override `baseUrl`.
54
+ // When set to false, absolute values for `url` will always be prepended by `baseUrl`.
55
+ allowAbsoluteUrls: true,
56
+ // `transformRequest` allows changes to the request data before it is sent to the server
57
+ // This is only applicable for request methods 'PUT', 'POST', 'PATCH' and 'DELETE'
58
+ // The last function in the array must return a string or an instance of Buffer, ArrayBuffer,
59
+ // FormData or Stream
60
+ // You may modify the headers object.
61
+ transformRequest: [function (data, headers) {
62
+ // Do whatever you want to transform the data
63
+
64
+ return data;
65
+ }],
66
+
67
+ // `transformResponse` allows changes to the response data to be made before
68
+ // it is passed to then/catch
69
+ transformResponse: [function (data) {
70
+ // Do whatever you want to transform the data
71
+
72
+ return data;
73
+ }],
74
+
75
+ // `headers` are custom headers to be sent
76
+ headers: {'X-Requested-With': 'XMLHttpRequest'},
77
+
78
+ // `params` are the URL parameters to be sent with the request
79
+ // Must be a plain object or a URLSearchParams object
80
+ // NOTE: params that are null or undefined are not rendered in the URL.
81
+ params: {
82
+ ID: 12345
83
+ },
84
+
85
+ // `paramsSerializer` is an optional config in charge of serializing `params`
86
+ paramsSerializer: {
87
+ encode?: (param: string): string => { /* Do custom ops here and return transformed string */ }, // custom encoder function; sends Key/Values in an iterative fashion
88
+ serialize?: (params: Record<string, any>, options?: ParamsSerializerOptions ), // mimic pre 1.x behavior and send entire params object to a custom serializer func. Allows consumer to control how params are serialized.
89
+ indexes: false // array indexes format (null - no brackets, false (default) - empty brackets, true - brackets with indexes)
90
+ },
91
+
92
+ // `data` is the data to be sent as the request body
93
+ // Only applicable for request methods 'PUT', 'POST', 'DELETE', and 'PATCH'
94
+ // When no `transformRequest` is set, must be of one of the following types:
95
+ // - string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams
96
+ // - Browser only: FormData, File, Blob
97
+ // - Node only: Stream, Buffer
98
+ data: {
99
+ firstName: 'Fred'
100
+ },
101
+
102
+ // syntax alternative to send data into the body
103
+ // method post
104
+ // only the value is sent, not the key
105
+ data: 'Country=Brasil&City=Belo Horizonte',
106
+
107
+ // `timeout` specifies the number of milliseconds before the request times out.
108
+ // If the request takes longer than `timeout`, the request will be aborted.
109
+ timeout: 1000, // default is `0` (no timeout)
110
+
111
+ // `withCredentials` indicates whether or not cross-site Access-Control requests
112
+ // should be made using credentials
113
+ withCredentials: false, // default
114
+
115
+ // `adapter` allows custom handling of requests which makes testing easier.
116
+ // Return a promise and supply a valid response (see lib/adapters/README.md).
117
+ adapter: function (config) {
118
+ /* ... */
119
+ },
120
+
121
+ // `auth` indicates that HTTP Basic auth should be used, and supplies credentials.
122
+ // This will set an `Authorization` header, overwriting any existing
123
+ // `Authorization` custom headers you have set using `headers`.
124
+ // Please note that only HTTP Basic auth is configurable through this parameter.
125
+ // For Bearer tokens and such, use `Authorization` custom headers instead.
126
+ auth: {
127
+ username: 'janedoe',
128
+ password: 's00pers3cret'
129
+ },
130
+
131
+ // `responseType` indicates the type of data that the server will respond with
132
+ // options are: 'arraybuffer', 'document', 'json', 'text', 'stream'
133
+ // browser only: 'blob'
134
+ responseType: 'json', // default
135
+
136
+ // `responseEncoding` indicates encoding to use for decoding responses (Node.js only)
137
+ // Note: Ignored for `responseType` of 'stream' or client-side requests
138
+ responseEncoding: 'utf8', // default
139
+
140
+ // `xsrfCookieName` is the name of the cookie to use as a value for xsrf token
141
+ xsrfCookieName: 'XSRF-TOKEN', // default
142
+
143
+ // `xsrfHeaderName` is the name of the http header that carries the xsrf token value
144
+ xsrfHeaderName: 'X-XSRF-TOKEN', // default
145
+
146
+ // `onUploadProgress` allows handling of progress events for uploads
147
+ // browser only
148
+ onUploadProgress: function (progressEvent) {
149
+ // Do whatever you want with the native progress event
150
+ },
151
+
152
+ // `onDownloadProgress` allows handling of progress events for downloads
153
+ // browser only
154
+ onDownloadProgress: function (progressEvent) {
155
+ // Do whatever you want with the native progress event
156
+ },
157
+
158
+ // `maxContentLength` defines the max size of the http response content in bytes allowed in node.js
159
+ maxContentLength: 2000,
160
+
161
+ // `maxBodyLength` (Node only option) defines the max size of the http request content in bytes allowed
162
+ maxBodyLength: 2000,
163
+
164
+ // `validateStatus` defines whether to resolve or reject the promise for a given
165
+ // HTTP response status code. If `validateStatus` returns `true` (or is set to `null`
166
+ // or `undefined`), the promise will be resolved; otherwise, the promise will be
167
+ // rejected.
168
+ validateStatus: function (status) {
169
+ return status >= 200 && status < 300; // default
170
+ },
171
+
172
+ // `maxRedirects` defines the maximum number of redirects to follow in node.js.
173
+ // If set to 0, no redirects will be followed.
174
+ maxRedirects: 21, // default
175
+
176
+ // `beforeRedirect` defines a function that will be called before redirect.
177
+ // Use this to adjust the request options upon redirecting,
178
+ // to inspect the latest response headers,
179
+ // or to cancel the request by throwing an error
180
+ // If maxRedirects is set to 0, `beforeRedirect` is not used.
181
+ beforeRedirect: (options, { headers }) => {
182
+ if (options.hostname === "example.com") {
183
+ options.auth = "user:password";
184
+ }
185
+ },
186
+
187
+ // `socketPath` defines a UNIX Socket to be used in node.js.
188
+ // e.g. '/var/run/docker.sock' to send requests to the docker daemon.
189
+ // Only either `socketPath` or `proxy` can be specified.
190
+ // If both are specified, `socketPath` is used.
191
+ socketPath: null, // default
192
+
193
+ // `transport` determines the transport method that will be used to make the request. If defined, it will be used. Otherwise, if `maxRedirects` is 0, the default `http` or `https` library will be used, depending on the protocol specified in `protocol`. Otherwise, the `httpFollow` or `httpsFollow` library will be used, again depending on the protocol, which can handle redirects.
194
+ transport: undefined, // default
195
+
196
+ // `httpAgent` and `httpsAgent` define a custom agent to be used when performing http
197
+ // and https requests, respectively, in node.js. This allows options to be added like
198
+ // `keepAlive` that are not enabled by default before Node.js v19.0.0. After Node.js
199
+ // v19.0.0, you no longer need to customize the agent to enable `keepAlive` because
200
+ // `http.globalAgent` has `keepAlive` enabled by default.
201
+ httpAgent: new http.Agent({ keepAlive: true }),
202
+ httpsAgent: new https.Agent({ keepAlive: true }),
203
+
204
+ // `proxy` defines the hostname, port, and protocol of the proxy server.
205
+ // You can also define your proxy using the conventional `http_proxy` and
206
+ // `https_proxy` environment variables. If you are using environment variables
207
+ // for your proxy configuration, you can also define a `no_proxy` environment
208
+ // variable as a comma-separated list of domains that should not be proxied.
209
+ // Use `false` to disable proxies, ignoring environment variables.
210
+ // Disable if supplying a custom httpAgent/httpsAgent to manage proxying requests.
211
+ // `auth` indicates that HTTP Basic auth should be used to connect to the proxy, and
212
+ // supplies credentials.
213
+ // This will set an `Proxy-Authorization` header, overwriting any existing
214
+ // `Proxy-Authorization` custom headers you have set using `headers`.
215
+ // If the proxy server uses HTTPS, then you must set the protocol to `https`.
216
+ proxy: {
217
+ protocol: 'https',
218
+ host: '127.0.0.1',
219
+ port: 9000,
220
+ auth: {
221
+ username: 'mikeymike',
222
+ password: 'rapunz3l'
223
+ }
224
+ },
225
+
226
+ // `signal` and instance of AbortController can be used to cancel the request
227
+ signal: new AbortController().signal,
228
+
229
+ // (Deprecated) `cancelToken` specifies a cancel token that can also be used to cancel the request
230
+ // (see Cancellation section below for details)
231
+ cancelToken: new CancelToken(function (cancel) {
232
+ }),
233
+
234
+ // an alternative way to cancel Axios requests using AbortController
235
+ signal: new AbortController().signal,
236
+
237
+ // `decompress` indicates whether or not the response body should be decompressed
238
+ // automatically. If set to `true` will also remove the 'content-encoding' header
239
+ // from the responses objects of all decompressed responses
240
+ // - Node only (XHR cannot turn off decompression)
241
+ decompress: true // default
242
+
243
+ // `insecureHTTPParser` boolean.
244
+ // Indicates where to use an insecure HTTP parser that accepts invalid HTTP headers.
245
+ // This may allow interoperability with non-conformant HTTP implementations.
246
+ // Using the insecure parser should be avoided.
247
+ // see options https://nodejs.org/dist/latest-v12.x/docs/api/http.html#http_http_request_url_options_callback
248
+ // see also https://nodejs.org/en/blog/vulnerability/february-2020-security-releases/#strict-http-header-parsing-none
249
+ insecureHTTPParser: undefined // default
250
+
251
+ // transitional options for backward compatibility that may be removed in the newer versions
252
+ transitional: {
253
+ // silent JSON parsing mode
254
+ // `true` - ignore JSON parsing errors and set response.data to null if parsing failed (old behaviour)
255
+ // `false` - throw SyntaxError if JSON parsing failed (Note: responseType must be set to 'json')
256
+ silentJSONParsing: true, // default value for the current Axios version
257
+
258
+ // try to parse the response string as JSON even if `responseType` is not 'json'
259
+ forcedJSONParsing: true,
260
+
261
+ // throw ETIMEDOUT error instead of generic ECONNABORTED on request timeouts
262
+ clarifyTimeoutError: false,
263
+ },
264
+
265
+ env: {
266
+ // The FormData class to be used to automatically serialize the payload into a FormData object
267
+ FormData: window?.FormData || global?.FormData
268
+ },
269
+
270
+ formSerializer: {
271
+ visitor: (value, key, path, helpers) => {}; // custom visitor function to serialize form values
272
+ dots: boolean; // use dots instead of brackets format
273
+ metaTokens: boolean; // keep special endings like {} in parameter key
274
+ indexes: boolean; // array indexes format null - no brackets, false - empty brackets, true - brackets with indexes
275
+ },
276
+
277
+ // http adapter only (node.js)
278
+ maxRate: [
279
+ 100 * 1024, // 100KB/s upload limit,
280
+ 100 * 1024 // 100KB/s download limit
281
+ ]
282
+ }
283
+ )
284
+ ```
285
+
286
+ # Feature
287
+ ## provider error global handler and request method custom error handler.
288
+ ## provider custom network response struct and custom network response code and so on.
289
+ ### 1. network response meaning is the response from the server.
290
+ ### 2. network response code meaning is the code from the server.
291
+ ### 3. server kill callback is the callback when the server is killed or the http status code range is not [200, 299]
292
+
293
+ ```ts
294
+ import { setupInterceptors, GlowPod } from "@andbridge/glowpod";
295
+
296
+ const { Post,getInstance } = new GlowPod({
297
+ baseURL: "https://api.github.com",
298
+ });
299
+
300
+ const instance = getInstance();
301
+
302
+ setupInterceptors({
303
+ // request instance must getInstance() return value
304
+ instance,
305
+ // auth failed callback default callback
306
+ authFailedCaller: () => {
307
+ alert("登录失效");
308
+ },
309
+ // server kill callback default callback
310
+ serverKillCaller: () => {
311
+ alert("服务器已关闭");
312
+ },
313
+ // network request failed callback default callback
314
+ networkFailedCaller: () => {
315
+ alert("网络请求异常");
316
+ },
317
+ /* network request response struct default response struct{
318
+ codeName: "code",
319
+ messageName: "message",
320
+ dataName: "data",
321
+ }
322
+ */
323
+ responseStruct: {
324
+ codeName: "code",
325
+ messageName: "message",
326
+ dataName: "data",
327
+ },
328
+ // auth token storage name default 'token'
329
+ authTokenStorageName: "token",
330
+ // auth failed code default 401
331
+ authFailedCode: 401,
332
+ // network success code default 200
333
+ networkSuccessCode: 200,
334
+ });
335
+
336
+ Post("/users/login", {})
337
+ ```
338
+
339
+ # last
340
+
341
+ ## If you still have questions or customization needs, you can leave me a message.
342
+
343
+
344
+