docs: updated sidebar and added dev mode section

This commit is contained in:
arthurfiorette 2022-01-23 16:44:00 -03:00
parent 2d779ec0da
commit cc6523f00c
No known key found for this signature in database
GPG Key ID: 9D190CD53C53C555
4 changed files with 61 additions and 23 deletions

View File

@ -1,26 +1,27 @@
- Getting Started - Getting Started
- [Homepage](/ 'Homepage') - [Homepage](/ 'Homepage')
- [Try it out!](pages/try-it-out.md 'Try axios-cache-interceptor') - [Try it out!](pages/try-it-out.md 'Try axios-cache-interceptor in your browser!')
- [Installing](pages/installing.md 'Installing') - [Installing](pages/installing.md 'Installing')
- [Usage & Examples](pages/usage-examples.md 'Interceptor') - [Usage & examples](pages/usage-examples.md 'Usage and examples')
- [Storages](pages/storages.md 'Custom storages') - [Storages](pages/storages.md 'Custom storages')
- Cache Interceptor API - Cache Interceptor API
- [Request ID](pages/request-id.md 'Request ID') - [Request Id](pages/request-id.md 'Request Id')
- [Global configuration](pages/global-configuration.md 'Global configuration') - [Global configuration](pages/global-configuration.md 'Global configuration')
- [Per request configuration](pages/per-request-configuration.md 'Per request configuration') - [Per request configuration](pages/per-request-configuration.md 'Per request configuration')
- [Response object](pages/response-object.md 'Response object') - [Response object](pages/response-object.md 'Response object')
- Extras - Extras
- [Typescript Users](pages/typescript-users.md 'Typescript users') - [Development mode](pages/development-mode.md 'Development mode')
- [Typescript users](pages/typescript-users.md 'Typescript users')
- [Compiled code](pages/compiled-code.md 'Compiled code') - [Compiled code](pages/compiled-code.md 'Compiled code')
- [Comparison](pages/comparison.md 'Comparison') - [Comparison](pages/comparison.md 'Comparison')
- Other - Other
- [License](pages/license.md 'License') - [License](pages/license.md 'License')
- [Contact & Security](pages/contact.md 'Contact & Security') - [Contact & security](pages/contact.md 'Contact & security')
- [Changelog](pages/changelog.md 'Changelog') - [Changelog](pages/changelog.md 'Changelog')

View File

@ -0,0 +1,48 @@
# Development
For development, debug and testing purposes, you can opt to use the **Development mode**.
It brings some extra features to our built code, like the `debug` option, source maps,
fewer code and etc.
You can enable it basically by using `/dev` at the end of the import path.
```js
import { setupCache } from 'axios-cache-interceptor/esm/dev';
const { setupCache } = require('axios-cache-interceptor/umd/dev');
// https://cdn.jsdelivr.net/npm/axios-cache-interceptor/umd/dev.js
const { setupCache } = window.AxiosCacheInterceptor;
```
## Debug option
The debug option will print debug information in the console. It is good if you need to
trace any undesired behavior or issue.
You can enable it by setting `debug` to a function that receives an string.
```js
// Will print debug info in the console.
setupCache(axios, {
debug: console.log
});
// own logger or whatever.
setupCache(axios, {
debug: (message) => {
// Etc
myCustomLogger.emit({
key: 'axios-cache-interceptor',
log: message
});
}
});
// Disables debug.
setupCache(axios, {
debug: undefined
});
// or
axiosCacheInstance.debug = undefined;
```

View File

@ -1,15 +1,4 @@
[![Issues](https://img.shields.io/github/issues/arthurfiorette/axios-cache-interceptor?logo=github&label=Issues)](https://github.com/arthurfiorette/axios-cache-interceptor/issues) # Homepage
[![Stars](https://img.shields.io/github/stars/arthurfiorette/axios-cache-interceptor?logo=github&label=Stars)](https://github.com/arthurfiorette/axios-cache-interceptor/stargazers)
[![License](https://img.shields.io/github/license/arthurfiorette/axios-cache-interceptor?logo=githu&label=License)](https://github.com/arthurfiorette/axios-cache-interceptor/blob/main/LICENSE)
[![Try on Runkit](https://img.shields.io/badge/try%20on-RunKit-brightgreen?logo=runkit&logoColor=e83e8c)](https://npm.runkit.com/axios-cache-interceptor)
[![Codecov](https://codecov.io/gh/arthurfiorette/axios-cache-interceptor/branch/main/graph/badge.svg?token=ML0KGCU0VM)](https://codecov.io/gh/arthurfiorette/axios-cache-interceptor)
[![Downloads](https://img.shields.io/npm/dw/axios-cache-interceptor?style=flat)](https://www.npmjs.com/package/axios-cache-interceptor)
[![Bundlephobia](https://img.shields.io/bundlephobia/minzip/axios-cache-interceptor/latest?style=flat)](https://bundlephobia.com/package/axios-cache-interceptor@latest)
[![Packagephobia](https://packagephobia.com/badge?p=axios-cache-interceptor@latest)](https://packagephobia.com/result?p=axios-cache-interceptor@latest)
<br />
## What is this library?
This package is an interceptor for [axios](https://axios-http.com/) that adds caching This package is an interceptor for [axios](https://axios-http.com/) that adds caching
capabilities to it. It is a simple, easy to use and powerful library. capabilities to it. It is a simple, easy to use and powerful library.

View File

@ -11,26 +11,26 @@ to the same id with `{ url: 'https://a.com/b/' }`.
Also, a custom id can be used to treat two requests as the same. Also, a custom id can be used to treat two requests as the same.
```js #runkit ```js #runkit
const Axios = require('axios'); const axios = require('axios');
const { setupCache } = require('axios-cache-interceptor'); const { setupCache } = require('axios-cache-interceptor');
// Global // Global
setupCache(Axios); setupCache(axios);
const { id } = await Axios.get('https://jsonplaceholder.typicode.com/posts/1', { const { id } = await axios.get('https://jsonplaceholder.typicode.com/posts/1', {
baseURL: 'baseURL', baseURL: 'baseURL',
query: { name: 'value' } query: { name: 'value' }
}); });
console.log('Id 1: ' + id); console.log('Id 1: ' + id);
console.log('Cache 1:', await Axios.storage.get(id)); console.log('Cache 1:', await axios.storage.get(id));
const { id: id2 } = await Axios.get('https://jsonplaceholder.typicode.com/posts/1', { const { id: id2 } = await axios.get('https://jsonplaceholder.typicode.com/posts/1', {
id: 'my-overridden-id' id: 'my-overridden-id'
}); });
console.log('Id 2: ' + id2); console.log('Id 2: ' + id2);
console.log('Cache 2:', await Axios.storage.get(id2)); console.log('Cache 2:', await axios.storage.get(id2));
``` ```
The The