Releases: jaredwray/cacheable
v10.0.0
Breaking Change with v10.0.0
This release contains breaking changes as we are now using class
to handle instances and hooks better. This is the new way to use this package.
Usage Before v10
import http from 'http';
import CacheableRequest from 'cacheable-request';
// Then instead of
const req = http.request('http://example.com', cb);
req.end();
// You can do
const cacheableRequest = new CacheableRequest(http.request);
const cacheReq = cacheableRequest('http://example.com', cb);
cacheReq.on('request', req => req.end());
// Future requests to 'example.com' will be returned from cache if still valid
// You pass in any other http.request API compatible method to be wrapped with cache support:
const cacheableRequest = new CacheableRequest(https.request);
const cacheableRequest = new CacheableRequest(electron.net);
Usage After v10
import CacheableRequest from 'cacheable-request';
// Now You can do
const cacheableRequest = new CacheableRequest(http.request).createCacheableRequest();
const cacheReq = cacheableRequest('http://example.com', cb);
cacheReq.on('request', req => req.end());
// Future requests to 'example.com' will be returned from cache if still valid
// You pass in any other http.request API compatible method to be wrapped with cache support:
const cacheableRequest = new CacheableRequest(https.request).createCacheableRequest();
const cacheableRequest = new CacheableRequest(electron.net).createCacheableRequest();
The biggest change is that when you do a new
CacheableRequest you now want to call createCacheableRequest
method will give you the instance to use.
- const cacheableRequest = new CacheableRequest(http.request);
+ const cacheableRequest = new CacheableRequest(http.request).createCacheableRequest();
What's Changed
- updating security readme on support for v8.x.x by @jaredwray in #166
- upgrading keyv to 4.4.1 by @jaredwray in #168
- upgrading ts-jest to 28.0.8 by @jaredwray in #169
- fixed hooks instance issue by @alphmth in #167
- fixed issue by @alphmth in #172
- fixed type issues by @alphmth in #173
- Issue #174 by @slwhitman in #176
- Issue 171 by @alphmth in #175
New Contributors
- @slwhitman made their first contribution in #176
Full Changelog: v9.0.0...v10.0.0
v9.0.0
v9 is now pure ESM 🎉
cacheable-request
is now pure ESM with version v9.0.0
and up. Version v.8.x.x
is the supported commonjs version which will get only major security fixes moving forward until end of 2022. If you would like to learn about uprgrading / using ESM @sindresorhus has an amazing reference guide here: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
Major thank you to @alphmth, @sindresorhus, @szmarczak, @jasonbaik, and everybody for help on this. 🙌
Special call out to @CyberShadow as in the previous release we forgot to mention the work done on issue #28 as without their guidance and code we wouldn't have fixed it. ❤️
Typescript
In addition to pure ESM we are now fulling using Typescript moving forward on this project which means all type definitions are now native with the service. 🤩
Hooks!
Hooks have been introduced for the response
object that will run a processing function like so if you wanted to do compression:
CacheableRequest.addHook('response', async (response: any) => {
const buffer = await pm(gunzip)(response);
return buffer.toString();
});
const cacheableRequest = CacheableRequest(request, cache);
How to Add a Hook: https://github.com/jaredwray/cacheable-request#add-hooks
How to Remove a Hook: https://github.com/jaredwray/cacheable-request#remove-hooks
We would love some feedback on this feature!
Change Log
- support esm by @alphmth in #145
- Moving to pure ESM by @jaredwray in #147
- upgrading jest and ts-node to latest by @jaredwray in #148
- fixed for 304 by @alphmth in #149
- upgrading ts-node to 10.9.1 by @jaredwray in #151
- upgrading xo to 0.51.0 by @jaredwray in #152
- upgrading jest and modules to latest by @jaredwray in #153
- upgrading @keyv/sqlite to 3.5.3 and sqlite3 to 5.0.10 by @jaredwray in #154
- upgrading keyv to 4.3.3 by @jaredwray in #155
- upgrading responseLink to 3.0.0 by @jaredwray in #156
- Issue 95 by @alphmth in #157
- upgrading sqlite3 to 5.0.11 by @jaredwray in #158
- upgrading eslint-plugin-jest to 26.7.0 by @jaredwray in #159
- Create PULL_REQUEST_TEMPLATE.md for use on pull requests by @jaredwray in #160
- upgrading @types/node and eslint-plugin-jest to latest by @jaredwray in #161
- removing console.log from tests by @jaredwray in #162
- added hook for pre computation on response by @alphmth in #163
- upgrading @types/node to 18.7.3 by @jaredwray in #164
Full Changelog: v8.3.1...v9.0.0
v8.3.1
What's Changed
- Typescript by @alphmth in #140
- support jest by @alphmth in #141
- Create SECURITY.md by @jaredwray in #142
- fixed line coverages by @alphmth in #143
- Typescript by @jaredwray in #144
Full Changelog: v8.0.1...v8.3.1
v8.0.1
What's Changed
- upgrading xo to version 0.50.0 by @jaredwray in #135
- updating readme for ESM support and removing this package by @jaredwray in #136
Full Changelog: v8.0.0...v8.0.1
v8.0.0
What's Changed
- removing funding as no longer needed by @jaredwray in #110
- Moving to GitHub workflows for testing by @jaredwray in #111
- upgrading eslint xo config to latest by @jaredwray in #112
- upgrading this module to version 1.1.0 by @jaredwray in #113
- upgrading sqlite3 to version 5.0.2 by @jaredwray in #114
- upgrading sqlite3 to version 5.0.3 by @jaredwray in #115
- upgrading nyc to version 15.1.0 by @jaredwray in #116
- upgrading delay to version 5.0.0 by @jaredwray in #117
- upgrading http-cache-semantics to version 4.1.0 by @jaredwray in #118
- upgrading pify to version 5.0.0 by @jaredwray in #119
- upgrading create-test-server to version 3.0.1 by @jaredwray in #120
- feat: optional keyv instance injection by @simonecorsi in #101
- fix(cacheableRequest): prevent collisions on POST, PUT, and PATCH by @elliotttf in #31
- test(100%): add case to reach coverage by @simonecorsi in #121
- upgrading kevy and @keyv/sqlite to latest by @jaredwray in #122
- license and package clean up by @jaredwray in #125
- fixed for node 14, 16, and 18 by @alphmth in #126
- upgrading ava to version 4.3.0 by @jaredwray in #128
- xo upgrade by @alphmth in #130
- removing lowercasekeys as no longer needed by @jaredwray in #131
- upgrading pify to version 6.0.0 by @jaredwray in #132
- Convert package to esm by @jasonbaik in #133
- upgrading normalize-url to version 7.0.3 by @jaredwray in #134
New Contributors
- @jaredwray made their first contribution in #110
- @simonecorsi made their first contribution in #101
- @elliotttf made their first contribution in #31
- @alphmth made their first contribution in #126
- @jasonbaik made their first contribution in #133
Full Changelog: v7.0.2...v8.0.0