From eea790b8de15956c04f5c9968e6a7053f8bd6426 Mon Sep 17 00:00:00 2001 From: Matt Zabriskie Date: Wed, 1 Jun 2016 13:16:16 -0600 Subject: [PATCH] Adding README to modules --- lib/adapters/README.md | 38 ++++++++++++++++++++++++++++++++++++++ lib/core/README.md | 7 +++++++ lib/helpers/README.md | 7 +++++++ 3 files changed, 52 insertions(+) create mode 100644 lib/adapters/README.md create mode 100644 lib/core/README.md create mode 100644 lib/helpers/README.md diff --git a/lib/adapters/README.md b/lib/adapters/README.md new file mode 100644 index 00000000..1ddee31b --- /dev/null +++ b/lib/adapters/README.md @@ -0,0 +1,38 @@ +# axios // adapters + +The modules under `adapters/` are modules that handle dispatching a request and settling a `Promise` once a response is received. + +## Example + +```js +var settle = require('../helpers/settle'); +var transformData = require('./../helpers/transformData'); + +module.exports myAdapter(resolve, reject, config) { + // At this point: + // - config has been merged with defaults + // - request transformers have already run + // - request interceptors have already run + + // Make the request using config provided/ + // Upon response settle the Promise + + var response = { + data: transformData( + responseData, + responseHeaders, + config.transformResponse + ), + status: request.status, + statusText: request.statusText, + headers: responseHeaders, + config: config, + request: request + }; + + settle(resolve, reject, response); + + // From here: + // - response interceptors will run +} +``` diff --git a/lib/core/README.md b/lib/core/README.md new file mode 100644 index 00000000..253bc486 --- /dev/null +++ b/lib/core/README.md @@ -0,0 +1,7 @@ +# axios // core + +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: + +- Dispatching requests +- Managing interceptors +- Handling config diff --git a/lib/helpers/README.md b/lib/helpers/README.md new file mode 100644 index 00000000..4ae34193 --- /dev/null +++ b/lib/helpers/README.md @@ -0,0 +1,7 @@ +# axios // helpers + +The modules found in `helpers/` should be generic modules that are _not_ specific to the domain logic of axios. These modules could theoretically be published to npm on their own and consumed by other modules or apps. Some examples of generic modules are things like: + +- Browser polyfills +- Managing cookies +- Parsing HTTP headers