Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

restify-etag-cache

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

restify-etag-cache - npm Package Compare versions

Comparing version 1.0.7 to 1.0.8

test.js

21

lib/index.js

@@ -8,12 +8,17 @@ 'use strict';

function eTagCache(options) {
function eTagCache(opts) {
let options;
options = opts || {};
/**
* TODO
* Implement the options logic.
* - ignore urls
* - ?
*/
function middleware(req, res, nextM) {
if (options.ignore_routes) {
if (options.ignore_routes.indexOf(req.route.path) > -1) {
return nextM();
}
} else if (options.ignore_urls) {
if (options.ignore_urls.indexOf(req.url) > -1) {
return nextM();
}
}
function middleware(req, res, nextM) {
let oldWrite,

@@ -20,0 +25,0 @@ oldWriteHead,

{
"name": "restify-etag-cache",
"version": "1.0.7",
"version": "1.0.8",
"description": "Restify ETag Cache. The easy way.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -23,4 +23,8 @@ # restify-etag-cache

var server = restify.createServer();
var options = {
ignore_routes : [ '/some/route/to/ignore/:withParam' ],
ignore_urls : [ '/some/specific/url/to/ignore' ]
};
server.use(restifyEtagCache());
server.use(restifyEtagCache(options));
```

@@ -32,1 +36,8 @@

## Options
At this time, there are only two options available:
ignore_urls
ignore_routes

@@ -10,3 +10,3 @@ 'use strict';

var SERVER,
let SERVER,
CLIENT,

@@ -52,3 +52,3 @@ PORT;

var opts = {
let opts = {
path: '/etag/foo',

@@ -77,3 +77,3 @@ headers: {

var opts = {
let opts = {
path: '/etag/foo',

@@ -99,3 +99,3 @@ headers: {}

var opts = {
let opts = {
path: '/etag/foo',

@@ -121,3 +121,3 @@ headers: {}

var opts = {
let opts = {
path: '/etag/foo',

@@ -134,2 +134,57 @@ headers: {

});
it('should ignore the specific route', function(done) {
let etagCacheOptions = {
ignore_routes: [ '/etag/:id' ]
};
SERVER.use(restifyEtagCache(etagCacheOptions));
SERVER.get('/etag/:id', function(req, res, next) {
res.send({
hello: 'world'
});
next();
});
let opts = {
path: '/etag/foo',
headers: {
'If-None-Match': '"11-+8JLzHoXlHWPwTJ/z+va9g"'
}
};
CLIENT.get(opts, function(err, _, res, obj) {
res.statusCode.should.equal(200);
done();
});
});
it('should ignore the specific url', function(done) {
let etagCacheOptions = {
ignore_urls: [ '/specific/url' ]
};
SERVER.use(restifyEtagCache(etagCacheOptions));
SERVER.get('/specific/url', function(req, res, next) {
res.send({
hello: 'world'
});
next();
});
let opts = {
path: '/specific/url',
headers: {
'If-None-Match': '"11-+8JLzHoXlHWPwTJ/z+va9g"'
}
};
CLIENT.get(opts, function(err, _, res, obj) {
res.statusCode.should.equal(200);
done();
});
});
});
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