cache-headers
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -29,3 +29,3 @@ /** | ||
/** | ||
* @param {object} config | ||
* @param {object} [config] | ||
* @param {object} [config.cacheSettings=undefined] Cache settings to override the default `paths` settings | ||
@@ -37,5 +37,7 @@ * @see module:cacheControl#generate for acceptable values | ||
function middleware(config) { | ||
var cacheSettings = config.cacheSettings; | ||
var paths = config.paths; | ||
var _ref = config || {}; | ||
var cacheSettings = _ref.cacheSettings; | ||
var paths = _ref.paths; | ||
return function (req, res, next) { | ||
@@ -42,0 +44,0 @@ |
{ | ||
"name": "cache-headers", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Generate browser and cdn cache header values", | ||
@@ -17,3 +17,11 @@ "main": "dist/index.js", | ||
}, | ||
"keywords": ["cache control", "last modified", "expires", "headers", "cache", "cdn", "response headers"], | ||
"keywords": [ | ||
"cache control", | ||
"last modified", | ||
"expires", | ||
"headers", | ||
"cache", | ||
"cdn", | ||
"response headers" | ||
], | ||
"author": "dale tan <dale@1stdibs.com> (https://1stdibs.com)", | ||
@@ -20,0 +28,0 @@ "repository": { |
@@ -6,3 +6,3 @@ # Cache Headers | ||
This package is developed using [ES6][es6-moz] and transpiled with [babel]. It is also using the [1stdibs eslint rules][eslint-rules] | ||
This package is developed using [ES6][es6-moz] and transpiled with [babel]. It is also using the [1stdibs eslint rules][eslint-rules]. | ||
@@ -17,2 +17,3 @@ ## Installation | ||
```sh | ||
$ npm install | ||
$ npm test | ||
@@ -97,3 +98,3 @@ ``` | ||
### cache.middleware (all optional properties) | ||
### cache.middleware (all properties optional) | ||
```js | ||
@@ -125,2 +126,6 @@ { | ||
## Contributing | ||
All code additions and bugfixes must be accompanied by unit tests. Tests are run with mocha and | ||
written with the node [`assert`][assert] module. | ||
## Acknowledgement | ||
@@ -134,1 +139,2 @@ A portion of this code was taken from this [cache-control][cache-control] package/repo. | ||
[cache-control]: https://github.com/divshot/cache-control | ||
[assert]: https://nodejs.org/api/assert.html |
@@ -24,3 +24,3 @@ /** | ||
/** | ||
* @param {object} config | ||
* @param {object} [config] | ||
* @param {object} [config.cacheSettings=undefined] Cache settings to override the default `paths` settings | ||
@@ -33,3 +33,3 @@ * @see module:cacheControl#generate for acceptable values | ||
const { cacheSettings, paths } = config; | ||
const { cacheSettings, paths } = config || {}; | ||
@@ -36,0 +36,0 @@ return (req, res, next) => { |
@@ -65,2 +65,13 @@ /** | ||
it('should set default values when nothing is passed in', (done) => { | ||
app = express(); | ||
agent = supertest(app); | ||
app.use(cacheControl.middleware()); | ||
agent | ||
.get('/root/sub') | ||
.expect('Cache-Control', 'max-age=600') | ||
.end(done); | ||
}); | ||
}); | ||
@@ -67,0 +78,0 @@ |
@@ -74,3 +74,3 @@ /** | ||
it('should create a new Date if an invalid date is passed in', (done) => { | ||
it('should create a new Date if an invalid date is passed in', () => { | ||
const invalid = new Date('asdfadsdf'); | ||
@@ -81,3 +81,2 @@ utils.getTimestamp(invalid) | ||
assert.strictEqual(actual, Number(expect)); | ||
done(); | ||
}); | ||
@@ -84,0 +83,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57980
1538
136