Skip to content

Commit

Permalink
Release 0.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanebachelier committed Apr 5, 2016
1 parent 84501a3 commit 44f7d36
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 51 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
<a name="0.8.0"></a>
# [0.8.0](https://github.com/stephanebachelier/superapi-cache/compare/0.8.0...v0.8.0) (2016-04-05)


### Features

* **exclude:** regroup all exclusion logic ([3184b20](https://github.com/stephanebachelier/superapi-cache/commit/3184b20))



<a name="0.7.1"></a>
## [0.7.1](https://github.com/stephanebachelier/superapi-cache/compare/0.7.1...v0.7.1) (2016-03-16)

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "superapi-cache",
"version": "0.8.0",
"version": "0.9.0",
"homepage": "https://github.com/stephanebachelier/superapi-cache",
"authors": [
"Stéphane Bachelier <[email protected]>"
Expand Down
42 changes: 42 additions & 0 deletions dist/exclude.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exclude;
function exclude(req, service) {
var exclusions = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];

if (service) {
if (service.use && service.use.cache === false) {
return true;
}
}

if (typeof exclusions.filter === 'function' && !exclusions.filter(req)) {
return true;
}

// do not cache request with query
if (exclusions.query && req.url.match(/\?.*$/)) {
return true;
}

var found = false;
var paths = exclusions.paths || [];

paths.forEach(function (regexp) {
if (req.url.match(regexp)) {
found = true;
return found;
}
});

if (found) {
return true;
}

// All rules explained. fo not rewrite regexp.
return false;
}
module.exports = exports['default'];
29 changes: 6 additions & 23 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ var _memory = require('./memory');

var _memory2 = _interopRequireDefault(_memory);

var _exclude = require('./exclude');

var _exclude2 = _interopRequireDefault(_exclude);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function cache() {
Expand All @@ -31,35 +35,14 @@ function cache() {
config.exclude = config.exclude || {};
config.exclude.query = config.exclude.query || true;
config.exclude.paths = config.exclude.paths || [];
config.exclude.filter = null;

if (config.log !== false) {
config.log = typeof config.log === 'function' ? config.log : console.log.bind(console);
}

return function (req, next, service) {
if (service) {
var useCache = !service.use || service.use && service.use.cache !== false;

if (!useCache) {
return null;
}
}

// do not cache request with query
if (config.exclude.query && req.url.match(/\?.*$/)) {
return null;
}

var found = false;

config.exclude.paths.forEach(function (regexp) {
if (req.url.match(regexp)) {
found = true;
return false;
}
});

if (found) {
if ((0, _exclude2.default)(req, service, config.exclude)) {
return null;
}

Expand Down
76 changes: 53 additions & 23 deletions dist/umd/superapi-cache.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/umd/superapi-cache.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/umd/superapi-cache.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/umd/superapi-cache.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "superapi-cache",
"version": "0.8.0",
"version": "0.9.0",
"description": "Caching module for superapi",
"homepage": "https://github.com/stephanebachelier/superapi-cache",
"author": {
Expand Down

0 comments on commit 44f7d36

Please sign in to comment.