@midwayjs/axios 3.0.0-beta.8 → 3.0.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../src/configuration.ts"],"names":[],"mappings":";;;;;;;;;AAAA,mDAAoD;AACpD,qDAA+C;AAY/C,IAAa,kBAAkB,GAA/B,MAAa,kBAAkB;IAC7B,KAAK,CAAC,OAAO,CAAC,SAAS;QACrB,MAAM,SAAS,CAAC,QAAQ,CAAC,4BAAW,CAAC,CAAC;IACxC,CAAC;CACF,CAAA;AAJY,kBAAkB;IAV9B,IAAA,yBAAa,EAAC;QACb,SAAS,EAAE,OAAO;QAClB,aAAa,EAAE;YACb;gBACE,OAAO,EAAE;oBACP,KAAK,EAAE,EAAE;iBACV;aACF;SACF;KACF,CAAC;GACW,kBAAkB,CAI9B;AAJY,gDAAkB","sourcesContent":["import { Configuration } from '@midwayjs/decorator';\nimport { HttpService } from './serviceManager';\n\n@Configuration({\n namespace: 'axios',\n importConfigs: [\n {\n default: {\n axios: {},\n },\n },\n ],\n})\nexport class AxiosConfiguration {\n async onReady(container) {\n await container.getAsync(HttpService);\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,iDAAsE;AAA7D,8GAAA,kBAAkB,OAAiB;AAC5C,8CAA4B;AAC5B,mDAAiC","sourcesContent":["export { AxiosConfiguration as Configuration } from './configuration';\nexport * from './interface';\nexport * from './serviceManager';\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interface.js","sourceRoot":"","sources":["../src/interface.ts"],"names":[],"mappings":";;;AAMa,QAAA,kBAAkB,GAAG,gBAAgB,CAAC","sourcesContent":["import {\n AxiosRequestConfig,\n AxiosResponse,\n AxiosInterceptorManager,\n} from 'axios';\n\nexport const AXIOS_INSTANCE_KEY = 'axios:instance';\n\nexport interface AxiosHttpService {\n interceptors: {\n request: AxiosInterceptorManager<AxiosRequestConfig>;\n response: AxiosInterceptorManager<AxiosResponse>;\n };\n getUri(config?: AxiosRequestConfig): string;\n request<T = any, R = AxiosResponse<T>>(\n config: AxiosRequestConfig\n ): Promise<R>;\n get<T = any, R = AxiosResponse<T>>(\n url: string,\n config?: AxiosRequestConfig\n ): Promise<R>;\n delete<T = any, R = AxiosResponse<T>>(\n url: string,\n config?: AxiosRequestConfig\n ): Promise<R>;\n head<T = any, R = AxiosResponse<T>>(\n url: string,\n config?: AxiosRequestConfig\n ): Promise<R>;\n options<T = any, R = AxiosResponse<T>>(\n url: string,\n config?: AxiosRequestConfig\n ): Promise<R>;\n post<T = any, R = AxiosResponse<T>>(\n url: string,\n data?: any,\n config?: AxiosRequestConfig\n ): Promise<R>;\n put<T = any, R = AxiosResponse<T>>(\n url: string,\n data?: any,\n config?: AxiosRequestConfig\n ): Promise<R>;\n patch<T = any, R = AxiosResponse<T>>(\n url: string,\n data?: any,\n config?: AxiosRequestConfig\n ): Promise<R>;\n}\n\ndeclare module '@midwayjs/core/dist/interface' {\n interface MidwayConfig {\n axios?: AxiosRequestConfig;\n }\n}\n\n"]}
@@ -7,8 +7,8 @@ export declare class HttpService implements AxiosHttpService {
7
7
  protected app: IMidwayApplication;
8
8
  protected httpConfig: AxiosRequestConfig;
9
9
  get interceptors(): {
10
- request: import("axios").AxiosInterceptorManager<AxiosRequestConfig>;
11
- response: import("axios").AxiosInterceptorManager<AxiosResponse<any>>;
10
+ request: import("axios").AxiosInterceptorManager<AxiosRequestConfig<any>>;
11
+ response: import("axios").AxiosInterceptorManager<AxiosResponse<any, any>>;
12
12
  };
13
13
  protected init(): Promise<void>;
14
14
  getUri(config?: AxiosRequestConfig): string;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serviceManager.js","sourceRoot":"","sources":["../src/serviceManager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iCAAgF;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A,kBAAM,EAAC,OAAO,CAAC;;+CACyB;AAOzC;IADC,IAAA,gBAAI,GAAE;;;;uCA0CN;AA1DU,WAAW;IADvB,IAAA,mBAAO,GAAE;GACG,WAAW,CAyHvB;AAzHY,kCAAW","sourcesContent":["import axios, { AxiosRequestConfig, AxiosInstance, AxiosResponse } from 'axios';\nimport { Provide, Inject, Init, Config, App } from '@midwayjs/decorator';\nimport { IMidwayApplication } from '@midwayjs/core';\nimport { AXIOS_INSTANCE_KEY, AxiosHttpService } from './interface';\n\n@Provide()\nexport class HttpService implements AxiosHttpService {\n private instance: AxiosInstance;\n\n @Inject()\n protected ctx: any;\n\n @App()\n protected app: IMidwayApplication;\n\n @Config('axios')\n protected httpConfig: AxiosRequestConfig;\n\n get interceptors() {\n return this.instance.interceptors;\n }\n\n @Init()\n protected async init() {\n if (\n !this.app.getApplicationContext().registry.hasObject(AXIOS_INSTANCE_KEY)\n ) {\n // 动态往全局容器中创建一个单例\n const instance = axios.create(this.httpConfig ?? {});\n\n // Add a request interceptor\n instance.interceptors.request.use(\n config => {\n // Do something before request is sent\n return config;\n },\n error => {\n // Do something with request error\n return Promise.reject(error);\n }\n );\n\n // Add a response interceptor\n instance.interceptors.response.use(\n response => {\n // Any status code that lie within the range of 2xx cause this function to trigger\n // Do something with response data\n return response;\n },\n error => {\n // Any status codes that falls outside the range of 2xx cause this function to trigger\n // Do something with response error\n return Promise.reject(error);\n }\n );\n\n this.app\n .getApplicationContext()\n .registry.registerObject(AXIOS_INSTANCE_KEY, instance);\n }\n\n this.instance = this.app\n .getApplicationContext()\n .registry.getObject(AXIOS_INSTANCE_KEY);\n }\n\n getUri(config?: AxiosRequestConfig): string {\n return this.instance.getUri(config);\n }\n\n request<T = any, R = AxiosResponse<T>>(\n config: AxiosRequestConfig\n ): Promise<R> {\n return this.instance.request(config);\n }\n\n get<T = any, R = AxiosResponse<T>>(\n url: string,\n config?: AxiosRequestConfig\n ): Promise<R> {\n return this.instance.get(url, config);\n }\n\n delete<T = any, R = AxiosResponse<T>>(\n url: string,\n config?: AxiosRequestConfig\n ): Promise<R> {\n return this.instance.delete(url, config);\n }\n\n head<T = any, R = AxiosResponse<T>>(\n url: string,\n config?: AxiosRequestConfig\n ): Promise<R> {\n return this.instance.head(url, config);\n }\n\n options<T = any, R = AxiosResponse<T>>(\n url: string,\n config?: AxiosRequestConfig\n ): Promise<R> {\n return this.instance.options(url, config);\n }\n\n post<T = any, R = AxiosResponse<T>>(\n url: string,\n data?: any,\n config?: AxiosRequestConfig\n ): Promise<R> {\n return this.instance.post(url, data, config);\n }\n\n put<T = any, R = AxiosResponse<T>>(\n url: string,\n data?: any,\n config?: AxiosRequestConfig\n ): Promise<R> {\n return this.instance.put(url, data, config);\n }\n\n patch<T = any, R = AxiosResponse<T>>(\n url: string,\n data?: any,\n config?: AxiosRequestConfig\n ): Promise<R> {\n return this.instance.patch(url, data, config);\n }\n}\n"]}
package/package.json CHANGED
@@ -1,20 +1,21 @@
1
1
  {
2
2
  "name": "@midwayjs/axios",
3
3
  "description": "midway http client with axios",
4
- "version": "3.0.0-beta.8",
4
+ "version": "3.0.2",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index.d.ts",
7
7
  "files": [
8
8
  "dist/**/*.js",
9
- "dist/**/*.d.ts"
9
+ "dist/**/*.d.ts",
10
+ "dist/**/*.js.map"
10
11
  ],
11
12
  "devDependencies": {
12
- "@midwayjs/core": "^3.0.0-beta.8",
13
- "@midwayjs/decorator": "^3.0.0-beta.8",
14
- "@midwayjs/mock": "^3.0.0-beta.8"
13
+ "@midwayjs/core": "^3.0.2",
14
+ "@midwayjs/decorator": "^3.0.2",
15
+ "@midwayjs/mock": "^3.0.2"
15
16
  },
16
17
  "dependencies": {
17
- "axios": "^0.21.1"
18
+ "axios": "^0.25.0"
18
19
  },
19
20
  "keywords": [
20
21
  "http client",
@@ -24,8 +25,8 @@
24
25
  "license": "MIT",
25
26
  "scripts": {
26
27
  "build": "tsc",
27
- "test": "node --require=ts-node/register ../../node_modules/.bin/jest",
28
- "cov": "node --require=ts-node/register ../../node_modules/.bin/jest --coverage --forceExit",
28
+ "test": "node --require=ts-node/register ../../node_modules/.bin/jest --runInBand",
29
+ "cov": "node --require=ts-node/register ../../node_modules/.bin/jest --runInBand --coverage --forceExit",
29
30
  "ci": "npm run test",
30
31
  "lint": "mwts check"
31
32
  },
@@ -36,5 +37,5 @@
36
37
  "type": "git",
37
38
  "url": "https://github.com/midwayjs/midway.git"
38
39
  },
39
- "gitHead": "bfafbdf8798f48d4daac5dd88ad53c6b2f33c110"
40
+ "gitHead": "ca77247d229978a736e79bb208579c014ed226fc"
40
41
  }
package/CHANGELOG.md DELETED
@@ -1,103 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- # [3.0.0-beta.8](https://github.com/midwayjs/midway/compare/v3.0.0-beta.7...v3.0.0-beta.8) (2021-12-08)
7
-
8
-
9
- ### Bug Fixes
10
-
11
- * express routing middleware takes effect at the controller level ([#1364](https://github.com/midwayjs/midway/issues/1364)) ([b9272e0](https://github.com/midwayjs/midway/commit/b9272e0971003443304b0c53815be31a0061b4bd))
12
-
13
-
14
-
15
-
16
-
17
- # [3.0.0-beta.7](https://github.com/midwayjs/midway/compare/v3.0.0-beta.6...v3.0.0-beta.7) (2021-12-03)
18
-
19
- **Note:** Version bump only for package @midwayjs/axios
20
-
21
-
22
-
23
-
24
-
25
- # [3.0.0-beta.6](https://github.com/midwayjs/midway/compare/v3.0.0-beta.5...v3.0.0-beta.6) (2021-11-26)
26
-
27
- **Note:** Version bump only for package @midwayjs/axios
28
-
29
-
30
-
31
-
32
-
33
- # [3.0.0-beta.5](https://github.com/midwayjs/midway/compare/v3.0.0-beta.4...v3.0.0-beta.5) (2021-11-25)
34
-
35
- **Note:** Version bump only for package @midwayjs/axios
36
-
37
-
38
-
39
-
40
-
41
- # [3.0.0-beta.4](https://github.com/midwayjs/midway/compare/v3.0.0-beta.3...v3.0.0-beta.4) (2021-11-24)
42
-
43
- **Note:** Version bump only for package @midwayjs/axios
44
-
45
-
46
-
47
-
48
-
49
- # [3.0.0-beta.3](https://github.com/midwayjs/midway/compare/v3.0.0-beta.2...v3.0.0-beta.3) (2021-11-18)
50
-
51
-
52
- ### Features
53
-
54
- * add component and framework config definition ([#1367](https://github.com/midwayjs/midway/issues/1367)) ([b2fe615](https://github.com/midwayjs/midway/commit/b2fe6157f99659471ff1333eca0b86bb889f61a3))
55
-
56
-
57
-
58
-
59
-
60
- # [3.0.0-beta.2](https://github.com/midwayjs/midway/compare/v3.0.0-beta.1...v3.0.0-beta.2) (2021-11-16)
61
-
62
- **Note:** Version bump only for package @midwayjs/axios
63
-
64
-
65
-
66
-
67
-
68
- # [3.0.0-beta.1](https://github.com/midwayjs/midway/compare/v2.12.4...v3.0.0-beta.1) (2021-11-14)
69
-
70
-
71
- ### Features
72
-
73
- * add redis component ([#1270](https://github.com/midwayjs/midway/issues/1270)) ([09c993a](https://github.com/midwayjs/midway/commit/09c993ac308d26fa9c742a659471c3f4cf5c5782))
74
-
75
-
76
-
77
-
78
-
79
- ## [2.12.4](https://github.com/midwayjs/midway/compare/v2.12.3...v2.12.4) (2021-08-13)
80
-
81
-
82
- ### Bug Fixes
83
-
84
- * post missing data ([#1225](https://github.com/midwayjs/midway/issues/1225)) ([ca99368](https://github.com/midwayjs/midway/commit/ca9936839d407c4c6e1a279eb57338e30a8cbb62))
85
-
86
-
87
-
88
-
89
-
90
- ## [2.12.3](https://github.com/midwayjs/midway/compare/v2.12.2...v2.12.3) (2021-08-09)
91
-
92
- **Note:** Version bump only for package @midwayjs/axios
93
-
94
-
95
-
96
-
97
-
98
- ## [2.12.1](https://github.com/midwayjs/midway/compare/v2.12.0...v2.12.1) (2021-08-01)
99
-
100
-
101
- ### Features
102
-
103
- * add http client component ([#1098](https://github.com/midwayjs/midway/issues/1098)) ([4e2f90a](https://github.com/midwayjs/midway/commit/4e2f90a9de946fa5abc2af4cd8a0ad9ee4188991))