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

express-lru

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-lru - npm Package Compare versions

Comparing version 0.1.0 to 1.0.0

4

index.js

@@ -6,3 +6,4 @@ var AsyncCache = require('async-cache');

var ttl = options.ttl || 30000;
var loader = new AsyncCache({max: 1000, maxAge: ttl, load: noop});
var max = options.max || 1000;
var loader = new AsyncCache({max: max, maxAge: ttl, load: noop});
var hasher = options.hasher || function(req) {

@@ -24,2 +25,3 @@ return req.originalUrl;

}
// we skip caching by returning an "error" to async-cache)
var nocache = res.statusCode && res.statusCode !== 200;

@@ -26,0 +28,0 @@ callback(nocache, {

{
"name": "express-lru",
"version": "0.1.0",
"version": "1.0.0",
"description": "Varnish-like cache middleware for Express",

@@ -22,3 +22,3 @@ "main": "index.js",

"author": "Brian Reavis <brian@naturalatlas.com>",
"license": "Apache License, v2.0",
"license": "Apache-2.0",
"bugs": {

@@ -25,0 +25,0 @@ "url": "https://github.com/naturalatlas/express-lru/issues"

@@ -17,3 +17,9 @@ # express-lru

var expresslru = require('express-lru');
var cache = expresslru({ttl: 60000, skip: function(req) { return !!req.user; }});
var cache = expresslru({
max: 1000,
ttl: 60000,
skip: function(req) {
return !!req.user;
}
});

@@ -27,3 +33,3 @@ app.get('/myroute', cache, function(req, res, next) {

Copyright &copy; 2015 [Natural Atlas, Inc.](https://github.com/naturalatlas) & [Contributors](https://github.com/naturalatlas/express-lru/graphs/contributors)
Copyright &copy; 2015–2016 [Natural Atlas, Inc.](https://github.com/naturalatlas) & [Contributors](https://github.com/naturalatlas/express-lru/graphs/contributors)

@@ -30,0 +36,0 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0

@@ -7,5 +7,6 @@ var async = require('async');

function runsequence(expectSkip, route, options, test, done) {
var app = express();
var agent = request.agent(app);
var app = express();
var agent = request.agent(app);
function runsequence(routePattern, expectSkip, route, options, test, done) {
options.ttl = 50;

@@ -15,3 +16,3 @@

var executions = 0;
app.get('/route', lru(options), function(req, res, next) {
app.get(routePattern, lru(options), function(req, res, next) {
executions++;

@@ -24,3 +25,3 @@ route(req, res, next);

setTimeout(function() {
var _agent = agent.get('/route');
var _agent = agent.get(routePattern);
test(_agent);

@@ -52,3 +53,3 @@ _agent.end(function(err) {

};
runsequence(false, route, {}, function(agent) {
runsequence('/route1', false, route, {}, function(agent) {
agent

@@ -66,3 +67,3 @@ .expect('Content-Type', /application\/json/)

};
runsequence(false, route, {}, function(agent) {
runsequence('/route2', false, route, {}, function(agent) {
agent

@@ -76,3 +77,3 @@ .expect('Content-Type', /text\/test/)

var route = function(req, res, next) { res.set({'Content-Type': 'text/test'}).send(new Buffer('hello')); };
runsequence(false, route, {}, function(agent) {
runsequence('/route3', false, route, {}, function(agent) {
agent

@@ -86,3 +87,3 @@ .expect('Content-Type', /text\/test/)

var route = function(req, res, next) { res.set({'Content-Type': 'text/test'}).send({a:'b'}); };
runsequence(false, route, {}, function(agent) {
runsequence('/route4', false, route, {}, function(agent) {
agent

@@ -100,3 +101,3 @@ .expect('Content-Type', /text\/test/)

};
runsequence(true, route, {}, function(agent) {
runsequence('/route5', true, route, {}, function(agent) {
agent

@@ -114,3 +115,3 @@ .expect('Content-Type', /text\/plain/)

var skip = function(req) { return true; };
runsequence(true, route, {skip: skip}, function(agent) {
runsequence('/route6', true, route, {skip: skip}, function(agent) {
agent

@@ -117,0 +118,0 @@ .expect('Content-Type', /text\/test/)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc