Skip to content

Commit 9b9f740

Browse files
committed
adding tests
1 parent 7bc5fc6 commit 9b9f740

File tree

6 files changed

+1005
-6
lines changed

6 files changed

+1005
-6
lines changed

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
language: node_js
3+
node_js:
4+
- "10"
5+
6+
install: npm install

index.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const CacheManager = require('cache-manager')
2-
const iu = require('middleware-if-unless')
2+
const iu = require('middleware-if-unless')()
33
const ms = require('ms')
44
const onEnd = require('on-http-end')
55
const getKeys = require('./get-keys')
@@ -16,7 +16,7 @@ const middleware = (opts) => async (req, res, next) => {
1616
// creating multi-cache instance
1717
const mcache = CacheManager.multiCaching(opts.stores)
1818

19-
if (req.cacheDisabled) return
19+
if (req.cacheDisabled) return next()
2020

2121
let { url, cacheAppendKey = req => '' } = req
2222
cacheAppendKey = await cacheAppendKey(req)
@@ -48,9 +48,6 @@ const middleware = (opts) => async (req, res, next) => {
4848
}
4949

5050
onEnd(res, (payload) => {
51-
// avoid double caching
52-
if (req.cacheHit) return
53-
5451
if (payload.headers[X_CACHE_EXPIRE]) {
5552
// support service level expiration
5653
const keysPattern = payload.headers[X_CACHE_EXPIRE]

0 commit comments

Comments
 (0)