New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cacheable-response

Package Overview
Dependencies
Maintainers
1
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cacheable-response - npm Package Compare versions

Comparing version

to
1.10.0

12

CHANGELOG.md

@@ -5,2 +5,14 @@ # Changelog

## [1.10.0](https://github.com/Kikobeats/cacheable-response/compare/v1.9.2...v1.10.0) (2019-12-07)
### Features
* add all options to getKey params ([a692392](https://github.com/Kikobeats/cacheable-response/commit/a69239276d06d5fd1bcea204989bc1bfa26e09b9))
### Bug Fixes
* linter ([9ef6331](https://github.com/Kikobeats/cacheable-response/commit/9ef633161bfcb72db76e345577543fbb21816545))
### [1.9.2](https://github.com/Kikobeats/cacheable-response/compare/v1.9.1...v1.9.2) (2019-11-25)

@@ -7,0 +19,0 @@

9

index.js

@@ -22,3 +22,3 @@ 'use strict'

const _getKey = req => {
const _getKey = ({ req }) => {
const url = new URL(req.url, 'http://localhost').toString()

@@ -83,10 +83,11 @@ const { origin } = new URL(url)

return async ({ req, res, ...opts }) => {
return async opts => {
const { req, res } = opts
const hasForce = Boolean(
req.query ? req.query.force : parse(req.url.split('?')[1]).force
)
const key = getKey(req, res)
const key = getKey(opts)
const cachedResult = await decompress(await cache.get(key))
const isHit = !hasForce && cachedResult !== undefined
const result = isHit ? cachedResult : await get({ req, res, ...opts })
const result = isHit ? cachedResult : await get(opts)

@@ -93,0 +94,0 @@ if (!result) return

@@ -5,3 +5,3 @@ {

"homepage": "https://nicedoc.io/Kikobeats/cacheable-response",
"version": "1.9.2",
"version": "1.10.0",
"main": "index.js",

@@ -15,2 +15,6 @@ "author": {

{
"name": "whooehoo",
"email": "whooehoo@yandex.ru"
},
{
"name": "Jakub Sarnowski",

@@ -26,6 +30,2 @@ "email": "jakub.sarnowski.st-yl.com"

"email": "rickynyairo@gmail.com"
},
{
"name": "whooehoo",
"email": "whooehoo@yandex.ru"
}

@@ -32,0 +32,0 @@ ],

@@ -188,3 +188,3 @@ # cacheable-response

Type: `function`<br/>
Default: `(req, res) => normalizeUrl(req.url)`
Default: `({ req }) => normalizeUrl(req.url)`

@@ -191,0 +191,0 @@ It determinates how the cache key should be computed, receiving `req, res` as input.