@aligent/cdk-prerender-proxy 0.2.7 → 2.0.1

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 (210) hide show
  1. package/index.js +1 -1
  2. package/index.ts +29 -0
  3. package/lib/error-response-construct.ts +54 -0
  4. package/lib/handlers/cache-control.ts +1 -4
  5. package/lib/handlers/error-response.ts +0 -1
  6. package/lib/handlers/prerender.ts +2 -3
  7. package/lib/prerender-cf-cache-control-construct.ts +58 -0
  8. package/lib/prerender-check-construct.ts +43 -0
  9. package/lib/prerender-construct.ts +55 -0
  10. package/lib/prerender-lambda-construct.ts +48 -0
  11. package/package.json +17 -26
  12. package/index.d.ts +0 -6
  13. package/lib/error-response-construct.d.ts +0 -9
  14. package/lib/error-response-construct.js +0 -32
  15. package/lib/handlers/node_modules/.package-lock.json +0 -55
  16. package/lib/handlers/node_modules/@types/aws-lambda/LICENSE +0 -21
  17. package/lib/handlers/node_modules/@types/aws-lambda/README.md +0 -16
  18. package/lib/handlers/node_modules/@types/aws-lambda/common/api-gateway.d.ts +0 -79
  19. package/lib/handlers/node_modules/@types/aws-lambda/common/cloudfront.d.ts +0 -79
  20. package/lib/handlers/node_modules/@types/aws-lambda/handler.d.ts +0 -171
  21. package/lib/handlers/node_modules/@types/aws-lambda/index.d.ts +0 -85
  22. package/lib/handlers/node_modules/@types/aws-lambda/package.json +0 -210
  23. package/lib/handlers/node_modules/@types/aws-lambda/trigger/alb.d.ts +0 -48
  24. package/lib/handlers/node_modules/@types/aws-lambda/trigger/api-gateway-authorizer.d.ts +0 -174
  25. package/lib/handlers/node_modules/@types/aws-lambda/trigger/api-gateway-proxy.d.ts +0 -187
  26. package/lib/handlers/node_modules/@types/aws-lambda/trigger/appsync-resolver.d.ts +0 -51
  27. package/lib/handlers/node_modules/@types/aws-lambda/trigger/cloudformation-custom-resource.d.ts +0 -68
  28. package/lib/handlers/node_modules/@types/aws-lambda/trigger/cloudfront-request.d.ts +0 -20
  29. package/lib/handlers/node_modules/@types/aws-lambda/trigger/cloudfront-response.d.ts +0 -21
  30. package/lib/handlers/node_modules/@types/aws-lambda/trigger/cloudwatch-events.d.ts +0 -8
  31. package/lib/handlers/node_modules/@types/aws-lambda/trigger/cloudwatch-logs.d.ts +0 -37
  32. package/lib/handlers/node_modules/@types/aws-lambda/trigger/codebuild-cloudwatch-state.d.ts +0 -104
  33. package/lib/handlers/node_modules/@types/aws-lambda/trigger/codepipeline-cloudwatch-action.d.ts +0 -31
  34. package/lib/handlers/node_modules/@types/aws-lambda/trigger/codepipeline-cloudwatch-pipeline.d.ts +0 -32
  35. package/lib/handlers/node_modules/@types/aws-lambda/trigger/codepipeline-cloudwatch-stage.d.ts +0 -23
  36. package/lib/handlers/node_modules/@types/aws-lambda/trigger/codepipeline-cloudwatch.d.ts +0 -11
  37. package/lib/handlers/node_modules/@types/aws-lambda/trigger/codepipeline.d.ts +0 -55
  38. package/lib/handlers/node_modules/@types/aws-lambda/trigger/cognito-user-pool-trigger/_common.d.ts +0 -41
  39. package/lib/handlers/node_modules/@types/aws-lambda/trigger/cognito-user-pool-trigger/create-auth-challenge.d.ts +0 -22
  40. package/lib/handlers/node_modules/@types/aws-lambda/trigger/cognito-user-pool-trigger/custom-email-sender.d.ts +0 -86
  41. package/lib/handlers/node_modules/@types/aws-lambda/trigger/cognito-user-pool-trigger/custom-message.d.ts +0 -44
  42. package/lib/handlers/node_modules/@types/aws-lambda/trigger/cognito-user-pool-trigger/define-auth-challenge.d.ts +0 -21
  43. package/lib/handlers/node_modules/@types/aws-lambda/trigger/cognito-user-pool-trigger/index.d.ts +0 -119
  44. package/lib/handlers/node_modules/@types/aws-lambda/trigger/cognito-user-pool-trigger/post-authentication.d.ts +0 -15
  45. package/lib/handlers/node_modules/@types/aws-lambda/trigger/cognito-user-pool-trigger/post-confirmation.d.ts +0 -22
  46. package/lib/handlers/node_modules/@types/aws-lambda/trigger/cognito-user-pool-trigger/pre-authentication.d.ts +0 -15
  47. package/lib/handlers/node_modules/@types/aws-lambda/trigger/cognito-user-pool-trigger/pre-signup.d.ts +0 -31
  48. package/lib/handlers/node_modules/@types/aws-lambda/trigger/cognito-user-pool-trigger/pre-token-generation.d.ts +0 -45
  49. package/lib/handlers/node_modules/@types/aws-lambda/trigger/cognito-user-pool-trigger/user-migration.d.ts +0 -39
  50. package/lib/handlers/node_modules/@types/aws-lambda/trigger/cognito-user-pool-trigger/verify-auth-challenge-response.d.ts +0 -20
  51. package/lib/handlers/node_modules/@types/aws-lambda/trigger/connect-contact-flow.d.ts +0 -65
  52. package/lib/handlers/node_modules/@types/aws-lambda/trigger/dynamodb-stream.d.ts +0 -45
  53. package/lib/handlers/node_modules/@types/aws-lambda/trigger/eventbridge.d.ts +0 -18
  54. package/lib/handlers/node_modules/@types/aws-lambda/trigger/iot.d.ts +0 -28
  55. package/lib/handlers/node_modules/@types/aws-lambda/trigger/kinesis-firehose-transformation.d.ts +0 -45
  56. package/lib/handlers/node_modules/@types/aws-lambda/trigger/kinesis-stream.d.ts +0 -28
  57. package/lib/handlers/node_modules/@types/aws-lambda/trigger/lex.d.ts +0 -116
  58. package/lib/handlers/node_modules/@types/aws-lambda/trigger/msk.d.ts +0 -21
  59. package/lib/handlers/node_modules/@types/aws-lambda/trigger/s3-batch.d.ts +0 -41
  60. package/lib/handlers/node_modules/@types/aws-lambda/trigger/s3.d.ts +0 -60
  61. package/lib/handlers/node_modules/@types/aws-lambda/trigger/ses.d.ts +0 -103
  62. package/lib/handlers/node_modules/@types/aws-lambda/trigger/sns.d.ts +0 -38
  63. package/lib/handlers/node_modules/@types/aws-lambda/trigger/sqs.d.ts +0 -46
  64. package/lib/handlers/node_modules/@types/node/LICENSE +0 -21
  65. package/lib/handlers/node_modules/@types/node/README.md +0 -16
  66. package/lib/handlers/node_modules/@types/node/assert/strict.d.ts +0 -4
  67. package/lib/handlers/node_modules/@types/node/assert.d.ts +0 -124
  68. package/lib/handlers/node_modules/@types/node/async_hooks.d.ts +0 -226
  69. package/lib/handlers/node_modules/@types/node/base.d.ts +0 -19
  70. package/lib/handlers/node_modules/@types/node/buffer.d.ts +0 -84
  71. package/lib/handlers/node_modules/@types/node/child_process.d.ts +0 -526
  72. package/lib/handlers/node_modules/@types/node/cluster.d.ts +0 -262
  73. package/lib/handlers/node_modules/@types/node/console.d.ts +0 -133
  74. package/lib/handlers/node_modules/@types/node/constants.d.ts +0 -13
  75. package/lib/handlers/node_modules/@types/node/crypto.d.ts +0 -1580
  76. package/lib/handlers/node_modules/@types/node/dgram.d.ts +0 -141
  77. package/lib/handlers/node_modules/@types/node/diagnostic_channel.d.ts +0 -34
  78. package/lib/handlers/node_modules/@types/node/dns/promises.d.ts +0 -97
  79. package/lib/handlers/node_modules/@types/node/dns.d.ts +0 -322
  80. package/lib/handlers/node_modules/@types/node/domain.d.ts +0 -24
  81. package/lib/handlers/node_modules/@types/node/events.d.ts +0 -93
  82. package/lib/handlers/node_modules/@types/node/fs/promises.d.ts +0 -592
  83. package/lib/handlers/node_modules/@types/node/fs.d.ts +0 -2239
  84. package/lib/handlers/node_modules/@types/node/globals.d.ts +0 -655
  85. package/lib/handlers/node_modules/@types/node/globals.global.d.ts +0 -1
  86. package/lib/handlers/node_modules/@types/node/http.d.ts +0 -434
  87. package/lib/handlers/node_modules/@types/node/http2.d.ts +0 -976
  88. package/lib/handlers/node_modules/@types/node/https.d.ts +0 -36
  89. package/lib/handlers/node_modules/@types/node/index.d.ts +0 -58
  90. package/lib/handlers/node_modules/@types/node/inspector.d.ts +0 -3041
  91. package/lib/handlers/node_modules/@types/node/module.d.ts +0 -52
  92. package/lib/handlers/node_modules/@types/node/net.d.ts +0 -326
  93. package/lib/handlers/node_modules/@types/node/os.d.ts +0 -239
  94. package/lib/handlers/node_modules/@types/node/package.json +0 -232
  95. package/lib/handlers/node_modules/@types/node/path.d.ts +0 -163
  96. package/lib/handlers/node_modules/@types/node/perf_hooks.d.ts +0 -310
  97. package/lib/handlers/node_modules/@types/node/process.d.ts +0 -461
  98. package/lib/handlers/node_modules/@types/node/punycode.d.ts +0 -75
  99. package/lib/handlers/node_modules/@types/node/querystring.d.ts +0 -28
  100. package/lib/handlers/node_modules/@types/node/readline.d.ts +0 -192
  101. package/lib/handlers/node_modules/@types/node/repl.d.ts +0 -395
  102. package/lib/handlers/node_modules/@types/node/stream/promises.d.ts +0 -67
  103. package/lib/handlers/node_modules/@types/node/stream.d.ts +0 -471
  104. package/lib/handlers/node_modules/@types/node/string_decoder.d.ts +0 -7
  105. package/lib/handlers/node_modules/@types/node/timers/promises.d.ts +0 -21
  106. package/lib/handlers/node_modules/@types/node/timers.d.ts +0 -27
  107. package/lib/handlers/node_modules/@types/node/tls.d.ts +0 -793
  108. package/lib/handlers/node_modules/@types/node/trace_events.d.ts +0 -61
  109. package/lib/handlers/node_modules/@types/node/ts3.6/assert.d.ts +0 -98
  110. package/lib/handlers/node_modules/@types/node/ts3.6/base.d.ts +0 -68
  111. package/lib/handlers/node_modules/@types/node/ts3.6/index.d.ts +0 -7
  112. package/lib/handlers/node_modules/@types/node/tty.d.ts +0 -66
  113. package/lib/handlers/node_modules/@types/node/url.d.ts +0 -116
  114. package/lib/handlers/node_modules/@types/node/util/types.d.ts +0 -53
  115. package/lib/handlers/node_modules/@types/node/util.d.ts +0 -156
  116. package/lib/handlers/node_modules/@types/node/v8.d.ts +0 -198
  117. package/lib/handlers/node_modules/@types/node/vm.d.ts +0 -152
  118. package/lib/handlers/node_modules/@types/node/wasi.d.ts +0 -86
  119. package/lib/handlers/node_modules/@types/node/worker_threads.d.ts +0 -282
  120. package/lib/handlers/node_modules/@types/node/zlib.d.ts +0 -361
  121. package/lib/handlers/node_modules/axios/CHANGELOG.md +0 -685
  122. package/lib/handlers/node_modules/axios/LICENSE +0 -19
  123. package/lib/handlers/node_modules/axios/README.md +0 -800
  124. package/lib/handlers/node_modules/axios/UPGRADE_GUIDE.md +0 -162
  125. package/lib/handlers/node_modules/axios/dist/axios.js +0 -1756
  126. package/lib/handlers/node_modules/axios/dist/axios.map +0 -1
  127. package/lib/handlers/node_modules/axios/dist/axios.min.js +0 -3
  128. package/lib/handlers/node_modules/axios/dist/axios.min.map +0 -1
  129. package/lib/handlers/node_modules/axios/index.d.ts +0 -161
  130. package/lib/handlers/node_modules/axios/index.js +0 -1
  131. package/lib/handlers/node_modules/axios/lib/adapters/README.md +0 -37
  132. package/lib/handlers/node_modules/axios/lib/adapters/http.js +0 -303
  133. package/lib/handlers/node_modules/axios/lib/adapters/xhr.js +0 -179
  134. package/lib/handlers/node_modules/axios/lib/axios.js +0 -56
  135. package/lib/handlers/node_modules/axios/lib/cancel/Cancel.js +0 -19
  136. package/lib/handlers/node_modules/axios/lib/cancel/CancelToken.js +0 -57
  137. package/lib/handlers/node_modules/axios/lib/cancel/isCancel.js +0 -5
  138. package/lib/handlers/node_modules/axios/lib/core/Axios.js +0 -95
  139. package/lib/handlers/node_modules/axios/lib/core/InterceptorManager.js +0 -52
  140. package/lib/handlers/node_modules/axios/lib/core/README.md +0 -7
  141. package/lib/handlers/node_modules/axios/lib/core/buildFullPath.js +0 -20
  142. package/lib/handlers/node_modules/axios/lib/core/createError.js +0 -18
  143. package/lib/handlers/node_modules/axios/lib/core/dispatchRequest.js +0 -79
  144. package/lib/handlers/node_modules/axios/lib/core/enhanceError.js +0 -42
  145. package/lib/handlers/node_modules/axios/lib/core/mergeConfig.js +0 -87
  146. package/lib/handlers/node_modules/axios/lib/core/settle.js +0 -25
  147. package/lib/handlers/node_modules/axios/lib/core/transformData.js +0 -20
  148. package/lib/handlers/node_modules/axios/lib/defaults.js +0 -98
  149. package/lib/handlers/node_modules/axios/lib/helpers/README.md +0 -7
  150. package/lib/handlers/node_modules/axios/lib/helpers/bind.js +0 -11
  151. package/lib/handlers/node_modules/axios/lib/helpers/buildURL.js +0 -70
  152. package/lib/handlers/node_modules/axios/lib/helpers/combineURLs.js +0 -14
  153. package/lib/handlers/node_modules/axios/lib/helpers/cookies.js +0 -53
  154. package/lib/handlers/node_modules/axios/lib/helpers/deprecatedMethod.js +0 -24
  155. package/lib/handlers/node_modules/axios/lib/helpers/isAbsoluteURL.js +0 -14
  156. package/lib/handlers/node_modules/axios/lib/helpers/isAxiosError.js +0 -11
  157. package/lib/handlers/node_modules/axios/lib/helpers/isURLSameOrigin.js +0 -68
  158. package/lib/handlers/node_modules/axios/lib/helpers/normalizeHeaderName.js +0 -12
  159. package/lib/handlers/node_modules/axios/lib/helpers/parseHeaders.js +0 -53
  160. package/lib/handlers/node_modules/axios/lib/helpers/spread.js +0 -27
  161. package/lib/handlers/node_modules/axios/lib/utils.js +0 -351
  162. package/lib/handlers/node_modules/axios/package.json +0 -86
  163. package/lib/handlers/node_modules/buffer-from/LICENSE +0 -21
  164. package/lib/handlers/node_modules/buffer-from/index.js +0 -69
  165. package/lib/handlers/node_modules/buffer-from/package.json +0 -19
  166. package/lib/handlers/node_modules/buffer-from/readme.md +0 -69
  167. package/lib/handlers/node_modules/follow-redirects/LICENSE +0 -18
  168. package/lib/handlers/node_modules/follow-redirects/README.md +0 -148
  169. package/lib/handlers/node_modules/follow-redirects/debug.js +0 -14
  170. package/lib/handlers/node_modules/follow-redirects/http.js +0 -1
  171. package/lib/handlers/node_modules/follow-redirects/https.js +0 -1
  172. package/lib/handlers/node_modules/follow-redirects/index.js +0 -531
  173. package/lib/handlers/node_modules/follow-redirects/package.json +0 -59
  174. package/lib/handlers/node_modules/source-map/CHANGELOG.md +0 -301
  175. package/lib/handlers/node_modules/source-map/LICENSE +0 -28
  176. package/lib/handlers/node_modules/source-map/README.md +0 -742
  177. package/lib/handlers/node_modules/source-map/dist/source-map.debug.js +0 -3234
  178. package/lib/handlers/node_modules/source-map/dist/source-map.js +0 -3233
  179. package/lib/handlers/node_modules/source-map/dist/source-map.min.js +0 -2
  180. package/lib/handlers/node_modules/source-map/dist/source-map.min.js.map +0 -1
  181. package/lib/handlers/node_modules/source-map/lib/array-set.js +0 -121
  182. package/lib/handlers/node_modules/source-map/lib/base64-vlq.js +0 -140
  183. package/lib/handlers/node_modules/source-map/lib/base64.js +0 -67
  184. package/lib/handlers/node_modules/source-map/lib/binary-search.js +0 -111
  185. package/lib/handlers/node_modules/source-map/lib/mapping-list.js +0 -79
  186. package/lib/handlers/node_modules/source-map/lib/quick-sort.js +0 -114
  187. package/lib/handlers/node_modules/source-map/lib/source-map-consumer.js +0 -1145
  188. package/lib/handlers/node_modules/source-map/lib/source-map-generator.js +0 -425
  189. package/lib/handlers/node_modules/source-map/lib/source-node.js +0 -413
  190. package/lib/handlers/node_modules/source-map/lib/util.js +0 -488
  191. package/lib/handlers/node_modules/source-map/package.json +0 -73
  192. package/lib/handlers/node_modules/source-map/source-map.d.ts +0 -98
  193. package/lib/handlers/node_modules/source-map/source-map.js +0 -8
  194. package/lib/handlers/node_modules/source-map-support/LICENSE.md +0 -21
  195. package/lib/handlers/node_modules/source-map-support/README.md +0 -284
  196. package/lib/handlers/node_modules/source-map-support/browser-source-map-support.js +0 -114
  197. package/lib/handlers/node_modules/source-map-support/package.json +0 -31
  198. package/lib/handlers/node_modules/source-map-support/register.js +0 -1
  199. package/lib/handlers/node_modules/source-map-support/source-map-support.js +0 -604
  200. package/lib/handlers/package-lock.json +0 -108
  201. package/lib/handlers/package.json +0 -13
  202. package/lib/handlers/tsconfig.json +0 -22
  203. package/lib/prerender-cf-cache-control-construct.d.ts +0 -10
  204. package/lib/prerender-cf-cache-control-construct.js +0 -33
  205. package/lib/prerender-check-construct.d.ts +0 -6
  206. package/lib/prerender-check-construct.js +0 -25
  207. package/lib/prerender-construct.d.ts +0 -11
  208. package/lib/prerender-construct.js +0 -34
  209. package/lib/prerender-lambda-construct.d.ts +0 -17
  210. package/lib/prerender-lambda-construct.js +0 -19
@@ -1,56 +0,0 @@
1
- 'use strict';
2
-
3
- var utils = require('./utils');
4
- var bind = require('./helpers/bind');
5
- var Axios = require('./core/Axios');
6
- var mergeConfig = require('./core/mergeConfig');
7
- var defaults = require('./defaults');
8
-
9
- /**
10
- * Create an instance of Axios
11
- *
12
- * @param {Object} defaultConfig The default config for the instance
13
- * @return {Axios} A new instance of Axios
14
- */
15
- function createInstance(defaultConfig) {
16
- var context = new Axios(defaultConfig);
17
- var instance = bind(Axios.prototype.request, context);
18
-
19
- // Copy axios.prototype to instance
20
- utils.extend(instance, Axios.prototype, context);
21
-
22
- // Copy context to instance
23
- utils.extend(instance, context);
24
-
25
- return instance;
26
- }
27
-
28
- // Create the default instance to be exported
29
- var axios = createInstance(defaults);
30
-
31
- // Expose Axios class to allow class inheritance
32
- axios.Axios = Axios;
33
-
34
- // Factory for creating new instances
35
- axios.create = function create(instanceConfig) {
36
- return createInstance(mergeConfig(axios.defaults, instanceConfig));
37
- };
38
-
39
- // Expose Cancel & CancelToken
40
- axios.Cancel = require('./cancel/Cancel');
41
- axios.CancelToken = require('./cancel/CancelToken');
42
- axios.isCancel = require('./cancel/isCancel');
43
-
44
- // Expose all/spread
45
- axios.all = function all(promises) {
46
- return Promise.all(promises);
47
- };
48
- axios.spread = require('./helpers/spread');
49
-
50
- // Expose isAxiosError
51
- axios.isAxiosError = require('./helpers/isAxiosError');
52
-
53
- module.exports = axios;
54
-
55
- // Allow use of default import syntax in TypeScript
56
- module.exports.default = axios;
@@ -1,19 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * A `Cancel` is an object that is thrown when an operation is canceled.
5
- *
6
- * @class
7
- * @param {string=} message The message.
8
- */
9
- function Cancel(message) {
10
- this.message = message;
11
- }
12
-
13
- Cancel.prototype.toString = function toString() {
14
- return 'Cancel' + (this.message ? ': ' + this.message : '');
15
- };
16
-
17
- Cancel.prototype.__CANCEL__ = true;
18
-
19
- module.exports = Cancel;
@@ -1,57 +0,0 @@
1
- 'use strict';
2
-
3
- var Cancel = require('./Cancel');
4
-
5
- /**
6
- * A `CancelToken` is an object that can be used to request cancellation of an operation.
7
- *
8
- * @class
9
- * @param {Function} executor The executor function.
10
- */
11
- function CancelToken(executor) {
12
- if (typeof executor !== 'function') {
13
- throw new TypeError('executor must be a function.');
14
- }
15
-
16
- var resolvePromise;
17
- this.promise = new Promise(function promiseExecutor(resolve) {
18
- resolvePromise = resolve;
19
- });
20
-
21
- var token = this;
22
- executor(function cancel(message) {
23
- if (token.reason) {
24
- // Cancellation has already been requested
25
- return;
26
- }
27
-
28
- token.reason = new Cancel(message);
29
- resolvePromise(token.reason);
30
- });
31
- }
32
-
33
- /**
34
- * Throws a `Cancel` if cancellation has been requested.
35
- */
36
- CancelToken.prototype.throwIfRequested = function throwIfRequested() {
37
- if (this.reason) {
38
- throw this.reason;
39
- }
40
- };
41
-
42
- /**
43
- * Returns an object that contains a new `CancelToken` and a function that, when called,
44
- * cancels the `CancelToken`.
45
- */
46
- CancelToken.source = function source() {
47
- var cancel;
48
- var token = new CancelToken(function executor(c) {
49
- cancel = c;
50
- });
51
- return {
52
- token: token,
53
- cancel: cancel
54
- };
55
- };
56
-
57
- module.exports = CancelToken;
@@ -1,5 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = function isCancel(value) {
4
- return !!(value && value.__CANCEL__);
5
- };
@@ -1,95 +0,0 @@
1
- 'use strict';
2
-
3
- var utils = require('./../utils');
4
- var buildURL = require('../helpers/buildURL');
5
- var InterceptorManager = require('./InterceptorManager');
6
- var dispatchRequest = require('./dispatchRequest');
7
- var mergeConfig = require('./mergeConfig');
8
-
9
- /**
10
- * Create a new instance of Axios
11
- *
12
- * @param {Object} instanceConfig The default config for the instance
13
- */
14
- function Axios(instanceConfig) {
15
- this.defaults = instanceConfig;
16
- this.interceptors = {
17
- request: new InterceptorManager(),
18
- response: new InterceptorManager()
19
- };
20
- }
21
-
22
- /**
23
- * Dispatch a request
24
- *
25
- * @param {Object} config The config specific for this request (merged with this.defaults)
26
- */
27
- Axios.prototype.request = function request(config) {
28
- /*eslint no-param-reassign:0*/
29
- // Allow for axios('example/url'[, config]) a la fetch API
30
- if (typeof config === 'string') {
31
- config = arguments[1] || {};
32
- config.url = arguments[0];
33
- } else {
34
- config = config || {};
35
- }
36
-
37
- config = mergeConfig(this.defaults, config);
38
-
39
- // Set config.method
40
- if (config.method) {
41
- config.method = config.method.toLowerCase();
42
- } else if (this.defaults.method) {
43
- config.method = this.defaults.method.toLowerCase();
44
- } else {
45
- config.method = 'get';
46
- }
47
-
48
- // Hook up interceptors middleware
49
- var chain = [dispatchRequest, undefined];
50
- var promise = Promise.resolve(config);
51
-
52
- this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
53
- chain.unshift(interceptor.fulfilled, interceptor.rejected);
54
- });
55
-
56
- this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
57
- chain.push(interceptor.fulfilled, interceptor.rejected);
58
- });
59
-
60
- while (chain.length) {
61
- promise = promise.then(chain.shift(), chain.shift());
62
- }
63
-
64
- return promise;
65
- };
66
-
67
- Axios.prototype.getUri = function getUri(config) {
68
- config = mergeConfig(this.defaults, config);
69
- return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
70
- };
71
-
72
- // Provide aliases for supported request methods
73
- utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
74
- /*eslint func-names:0*/
75
- Axios.prototype[method] = function(url, config) {
76
- return this.request(mergeConfig(config || {}, {
77
- method: method,
78
- url: url,
79
- data: (config || {}).data
80
- }));
81
- };
82
- });
83
-
84
- utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
85
- /*eslint func-names:0*/
86
- Axios.prototype[method] = function(url, data, config) {
87
- return this.request(mergeConfig(config || {}, {
88
- method: method,
89
- url: url,
90
- data: data
91
- }));
92
- };
93
- });
94
-
95
- module.exports = Axios;
@@ -1,52 +0,0 @@
1
- 'use strict';
2
-
3
- var utils = require('./../utils');
4
-
5
- function InterceptorManager() {
6
- this.handlers = [];
7
- }
8
-
9
- /**
10
- * Add a new interceptor to the stack
11
- *
12
- * @param {Function} fulfilled The function to handle `then` for a `Promise`
13
- * @param {Function} rejected The function to handle `reject` for a `Promise`
14
- *
15
- * @return {Number} An ID used to remove interceptor later
16
- */
17
- InterceptorManager.prototype.use = function use(fulfilled, rejected) {
18
- this.handlers.push({
19
- fulfilled: fulfilled,
20
- rejected: rejected
21
- });
22
- return this.handlers.length - 1;
23
- };
24
-
25
- /**
26
- * Remove an interceptor from the stack
27
- *
28
- * @param {Number} id The ID that was returned by `use`
29
- */
30
- InterceptorManager.prototype.eject = function eject(id) {
31
- if (this.handlers[id]) {
32
- this.handlers[id] = null;
33
- }
34
- };
35
-
36
- /**
37
- * Iterate over all the registered interceptors
38
- *
39
- * This method is particularly useful for skipping over any
40
- * interceptors that may have become `null` calling `eject`.
41
- *
42
- * @param {Function} fn The function to call for each interceptor
43
- */
44
- InterceptorManager.prototype.forEach = function forEach(fn) {
45
- utils.forEach(this.handlers, function forEachHandler(h) {
46
- if (h !== null) {
47
- fn(h);
48
- }
49
- });
50
- };
51
-
52
- module.exports = InterceptorManager;
@@ -1,7 +0,0 @@
1
- # axios // core
2
-
3
- The modules found in `core/` should be modules that are specific to the domain logic of axios. These modules would most likely not make sense to be consumed outside of the axios module, as their logic is too specific. Some examples of core modules are:
4
-
5
- - Dispatching requests
6
- - Managing interceptors
7
- - Handling config
@@ -1,20 +0,0 @@
1
- 'use strict';
2
-
3
- var isAbsoluteURL = require('../helpers/isAbsoluteURL');
4
- var combineURLs = require('../helpers/combineURLs');
5
-
6
- /**
7
- * Creates a new URL by combining the baseURL with the requestedURL,
8
- * only when the requestedURL is not already an absolute URL.
9
- * If the requestURL is absolute, this function returns the requestedURL untouched.
10
- *
11
- * @param {string} baseURL The base URL
12
- * @param {string} requestedURL Absolute or relative URL to combine
13
- * @returns {string} The combined full path
14
- */
15
- module.exports = function buildFullPath(baseURL, requestedURL) {
16
- if (baseURL && !isAbsoluteURL(requestedURL)) {
17
- return combineURLs(baseURL, requestedURL);
18
- }
19
- return requestedURL;
20
- };
@@ -1,18 +0,0 @@
1
- 'use strict';
2
-
3
- var enhanceError = require('./enhanceError');
4
-
5
- /**
6
- * Create an Error with the specified message, config, error code, request and response.
7
- *
8
- * @param {string} message The error message.
9
- * @param {Object} config The config.
10
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
11
- * @param {Object} [request] The request.
12
- * @param {Object} [response] The response.
13
- * @returns {Error} The created error.
14
- */
15
- module.exports = function createError(message, config, code, request, response) {
16
- var error = new Error(message);
17
- return enhanceError(error, config, code, request, response);
18
- };
@@ -1,79 +0,0 @@
1
- 'use strict';
2
-
3
- var utils = require('./../utils');
4
- var transformData = require('./transformData');
5
- var isCancel = require('../cancel/isCancel');
6
- var defaults = require('../defaults');
7
-
8
- /**
9
- * Throws a `Cancel` if cancellation has been requested.
10
- */
11
- function throwIfCancellationRequested(config) {
12
- if (config.cancelToken) {
13
- config.cancelToken.throwIfRequested();
14
- }
15
- }
16
-
17
- /**
18
- * Dispatch a request to the server using the configured adapter.
19
- *
20
- * @param {object} config The config that is to be used for the request
21
- * @returns {Promise} The Promise to be fulfilled
22
- */
23
- module.exports = function dispatchRequest(config) {
24
- throwIfCancellationRequested(config);
25
-
26
- // Ensure headers exist
27
- config.headers = config.headers || {};
28
-
29
- // Transform request data
30
- config.data = transformData(
31
- config.data,
32
- config.headers,
33
- config.transformRequest
34
- );
35
-
36
- // Flatten headers
37
- config.headers = utils.merge(
38
- config.headers.common || {},
39
- config.headers[config.method] || {},
40
- config.headers
41
- );
42
-
43
- utils.forEach(
44
- ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
45
- function cleanHeaderConfig(method) {
46
- delete config.headers[method];
47
- }
48
- );
49
-
50
- var adapter = config.adapter || defaults.adapter;
51
-
52
- return adapter(config).then(function onAdapterResolution(response) {
53
- throwIfCancellationRequested(config);
54
-
55
- // Transform response data
56
- response.data = transformData(
57
- response.data,
58
- response.headers,
59
- config.transformResponse
60
- );
61
-
62
- return response;
63
- }, function onAdapterRejection(reason) {
64
- if (!isCancel(reason)) {
65
- throwIfCancellationRequested(config);
66
-
67
- // Transform response data
68
- if (reason && reason.response) {
69
- reason.response.data = transformData(
70
- reason.response.data,
71
- reason.response.headers,
72
- config.transformResponse
73
- );
74
- }
75
- }
76
-
77
- return Promise.reject(reason);
78
- });
79
- };
@@ -1,42 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * Update an Error with the specified config, error code, and response.
5
- *
6
- * @param {Error} error The error to update.
7
- * @param {Object} config The config.
8
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
9
- * @param {Object} [request] The request.
10
- * @param {Object} [response] The response.
11
- * @returns {Error} The error.
12
- */
13
- module.exports = function enhanceError(error, config, code, request, response) {
14
- error.config = config;
15
- if (code) {
16
- error.code = code;
17
- }
18
-
19
- error.request = request;
20
- error.response = response;
21
- error.isAxiosError = true;
22
-
23
- error.toJSON = function toJSON() {
24
- return {
25
- // Standard
26
- message: this.message,
27
- name: this.name,
28
- // Microsoft
29
- description: this.description,
30
- number: this.number,
31
- // Mozilla
32
- fileName: this.fileName,
33
- lineNumber: this.lineNumber,
34
- columnNumber: this.columnNumber,
35
- stack: this.stack,
36
- // Axios
37
- config: this.config,
38
- code: this.code
39
- };
40
- };
41
- return error;
42
- };
@@ -1,87 +0,0 @@
1
- 'use strict';
2
-
3
- var utils = require('../utils');
4
-
5
- /**
6
- * Config-specific merge-function which creates a new config-object
7
- * by merging two configuration objects together.
8
- *
9
- * @param {Object} config1
10
- * @param {Object} config2
11
- * @returns {Object} New object resulting from merging config2 to config1
12
- */
13
- module.exports = function mergeConfig(config1, config2) {
14
- // eslint-disable-next-line no-param-reassign
15
- config2 = config2 || {};
16
- var config = {};
17
-
18
- var valueFromConfig2Keys = ['url', 'method', 'data'];
19
- var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params'];
20
- var defaultToConfig2Keys = [
21
- 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
22
- 'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
23
- 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress',
24
- 'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent',
25
- 'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding'
26
- ];
27
- var directMergeKeys = ['validateStatus'];
28
-
29
- function getMergedValue(target, source) {
30
- if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
31
- return utils.merge(target, source);
32
- } else if (utils.isPlainObject(source)) {
33
- return utils.merge({}, source);
34
- } else if (utils.isArray(source)) {
35
- return source.slice();
36
- }
37
- return source;
38
- }
39
-
40
- function mergeDeepProperties(prop) {
41
- if (!utils.isUndefined(config2[prop])) {
42
- config[prop] = getMergedValue(config1[prop], config2[prop]);
43
- } else if (!utils.isUndefined(config1[prop])) {
44
- config[prop] = getMergedValue(undefined, config1[prop]);
45
- }
46
- }
47
-
48
- utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
49
- if (!utils.isUndefined(config2[prop])) {
50
- config[prop] = getMergedValue(undefined, config2[prop]);
51
- }
52
- });
53
-
54
- utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties);
55
-
56
- utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
57
- if (!utils.isUndefined(config2[prop])) {
58
- config[prop] = getMergedValue(undefined, config2[prop]);
59
- } else if (!utils.isUndefined(config1[prop])) {
60
- config[prop] = getMergedValue(undefined, config1[prop]);
61
- }
62
- });
63
-
64
- utils.forEach(directMergeKeys, function merge(prop) {
65
- if (prop in config2) {
66
- config[prop] = getMergedValue(config1[prop], config2[prop]);
67
- } else if (prop in config1) {
68
- config[prop] = getMergedValue(undefined, config1[prop]);
69
- }
70
- });
71
-
72
- var axiosKeys = valueFromConfig2Keys
73
- .concat(mergeDeepPropertiesKeys)
74
- .concat(defaultToConfig2Keys)
75
- .concat(directMergeKeys);
76
-
77
- var otherKeys = Object
78
- .keys(config1)
79
- .concat(Object.keys(config2))
80
- .filter(function filterAxiosKeys(key) {
81
- return axiosKeys.indexOf(key) === -1;
82
- });
83
-
84
- utils.forEach(otherKeys, mergeDeepProperties);
85
-
86
- return config;
87
- };
@@ -1,25 +0,0 @@
1
- 'use strict';
2
-
3
- var createError = require('./createError');
4
-
5
- /**
6
- * Resolve or reject a Promise based on response status.
7
- *
8
- * @param {Function} resolve A function that resolves the promise.
9
- * @param {Function} reject A function that rejects the promise.
10
- * @param {object} response The response.
11
- */
12
- module.exports = function settle(resolve, reject, response) {
13
- var validateStatus = response.config.validateStatus;
14
- if (!response.status || !validateStatus || validateStatus(response.status)) {
15
- resolve(response);
16
- } else {
17
- reject(createError(
18
- 'Request failed with status code ' + response.status,
19
- response.config,
20
- null,
21
- response.request,
22
- response
23
- ));
24
- }
25
- };
@@ -1,20 +0,0 @@
1
- 'use strict';
2
-
3
- var utils = require('./../utils');
4
-
5
- /**
6
- * Transform the data for a request or a response
7
- *
8
- * @param {Object|String} data The data to be transformed
9
- * @param {Array} headers The headers for the request or response
10
- * @param {Array|Function} fns A single function or Array of functions
11
- * @returns {*} The resulting transformed data
12
- */
13
- module.exports = function transformData(data, headers, fns) {
14
- /*eslint no-param-reassign:0*/
15
- utils.forEach(fns, function transform(fn) {
16
- data = fn(data, headers);
17
- });
18
-
19
- return data;
20
- };
@@ -1,98 +0,0 @@
1
- 'use strict';
2
-
3
- var utils = require('./utils');
4
- var normalizeHeaderName = require('./helpers/normalizeHeaderName');
5
-
6
- var DEFAULT_CONTENT_TYPE = {
7
- 'Content-Type': 'application/x-www-form-urlencoded'
8
- };
9
-
10
- function setContentTypeIfUnset(headers, value) {
11
- if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
12
- headers['Content-Type'] = value;
13
- }
14
- }
15
-
16
- function getDefaultAdapter() {
17
- var adapter;
18
- if (typeof XMLHttpRequest !== 'undefined') {
19
- // For browsers use XHR adapter
20
- adapter = require('./adapters/xhr');
21
- } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
22
- // For node use HTTP adapter
23
- adapter = require('./adapters/http');
24
- }
25
- return adapter;
26
- }
27
-
28
- var defaults = {
29
- adapter: getDefaultAdapter(),
30
-
31
- transformRequest: [function transformRequest(data, headers) {
32
- normalizeHeaderName(headers, 'Accept');
33
- normalizeHeaderName(headers, 'Content-Type');
34
- if (utils.isFormData(data) ||
35
- utils.isArrayBuffer(data) ||
36
- utils.isBuffer(data) ||
37
- utils.isStream(data) ||
38
- utils.isFile(data) ||
39
- utils.isBlob(data)
40
- ) {
41
- return data;
42
- }
43
- if (utils.isArrayBufferView(data)) {
44
- return data.buffer;
45
- }
46
- if (utils.isURLSearchParams(data)) {
47
- setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
48
- return data.toString();
49
- }
50
- if (utils.isObject(data)) {
51
- setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
52
- return JSON.stringify(data);
53
- }
54
- return data;
55
- }],
56
-
57
- transformResponse: [function transformResponse(data) {
58
- /*eslint no-param-reassign:0*/
59
- if (typeof data === 'string') {
60
- try {
61
- data = JSON.parse(data);
62
- } catch (e) { /* Ignore */ }
63
- }
64
- return data;
65
- }],
66
-
67
- /**
68
- * A timeout in milliseconds to abort a request. If set to 0 (default) a
69
- * timeout is not created.
70
- */
71
- timeout: 0,
72
-
73
- xsrfCookieName: 'XSRF-TOKEN',
74
- xsrfHeaderName: 'X-XSRF-TOKEN',
75
-
76
- maxContentLength: -1,
77
- maxBodyLength: -1,
78
-
79
- validateStatus: function validateStatus(status) {
80
- return status >= 200 && status < 300;
81
- }
82
- };
83
-
84
- defaults.headers = {
85
- common: {
86
- 'Accept': 'application/json, text/plain, */*'
87
- }
88
- };
89
-
90
- utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
91
- defaults.headers[method] = {};
92
- });
93
-
94
- utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
95
- defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
96
- });
97
-
98
- module.exports = defaults;