Comparing version 1.0.6 to 1.0.7
/* jshint node:true */ | ||
/* global Promise */ | ||
'use strict'; | ||
var clone = require('clone'); | ||
var clone = require('clone'), | ||
Promise = require('bluebird'); | ||
@@ -8,0 +8,0 @@ function Cache(config) { |
/* jshint node:true */ | ||
/* global Promise */ | ||
@@ -7,3 +6,4 @@ 'use strict'; | ||
var request = require('request'), | ||
url = require('url'); | ||
url = require('url'), | ||
Promise = require('bluebird'); | ||
@@ -10,0 +10,0 @@ function DataProvider(config) { |
/* jshint node:true */ | ||
/* global Promise */ | ||
@@ -9,3 +8,4 @@ 'use strict'; | ||
DataProvider = require('./data-provider'), | ||
Logger = require('./logger'); | ||
Logger = require('./logger'), | ||
Promise = require('bluebird'); | ||
@@ -12,0 +12,0 @@ function ESI(config) { |
{ | ||
"name": "nodesi", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "ESI: the good parts in node.js", | ||
@@ -14,2 +14,3 @@ "main": "esi.js", | ||
"dependencies": { | ||
"bluebird": "2.9.14", | ||
"clone": "1.0.1", | ||
@@ -16,0 +17,0 @@ "request": "2.53.0" |
@@ -1,9 +0,61 @@ | ||
## Performance testing | ||
## What is this? | ||
You can run performance tests with ```npm run perf [args]``` | ||
It's a subset of [Edge Side Include](http://www.akamai.com/html/support/esi.html) standard implemented with [promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)-based interface. | ||
This tool assumes you have [Siege](http://www.joedog.org/siege-home/) installed and added to your Path variable. | ||
## Features | ||
[args] are list of arguments that will be passed to Siege. | ||
* Support for <esi:include> tags | ||
* Built-in memory cache (easily replaceable) | ||
* Cache respects Cache-Control server header | ||
* Graceful degradation to custom content upon server error | ||
* Custom logging | ||
...and more, take a look at test cases for complete list. | ||
## Installation | ||
```npm install nodesi``` | ||
## Usage | ||
#### Basic: | ||
```javascript | ||
var ESI = require('nodesi'); | ||
var esi = new ESI(); | ||
esi.process('<esi:include src="http://full-resource-path/stuff.html" />').then(function(result) { | ||
// result is a fetched html | ||
}); | ||
``` | ||
#### With base URL for relative paths: | ||
```javascript | ||
var ESI = require('nodesi'); | ||
var esi = new ESI({ | ||
baseUrl: 'http://full-resource-path' | ||
}); | ||
esi.process('<esi:include src="/stuff.html" />').then(function(result) { | ||
// result is a fetched html | ||
}); | ||
``` | ||
## Error handling | ||
You can provide onError callback to a ESI constructor. It will recieve two arguments: source URL and error object. | ||
It should return a string that will be put in place of errorous content. | ||
#### Example | ||
```javascript | ||
var esi = new ESI({ | ||
onError: function(src, error) { | ||
if(error.statusCode === 404) { | ||
return 'Not found'; | ||
} | ||
return ''; | ||
} | ||
}); | ||
``` | ||
## Logging | ||
@@ -22,3 +74,3 @@ | ||
```javascript | ||
new ESI({ | ||
var esi = new ESI({ | ||
logTo: { | ||
@@ -34,3 +86,3 @@ write: function(log) { | ||
```javascript | ||
new ESI({ | ||
var esi = new ESI({ | ||
logTo: process.stdout | ||
@@ -40,8 +92,16 @@ }); | ||
Logging to a file (possible, but please don't do that - http://12factor.net/logs): | ||
Logging to a file (possible, [but please don't do that](http://12factor.net/logs)): | ||
```javascript | ||
var logFile = require('fs').createWriteStream('./log.txt'); | ||
new ESI({ | ||
var esi = new ESI({ | ||
logTo: logFile | ||
}); | ||
``` | ||
``` | ||
## Performance testing | ||
You can run performance tests with ```npm run perf [args]``` | ||
This tool assumes you have [Siege](http://www.joedog.org/siege-home/) installed and added to your Path variable. | ||
[args] are list of arguments that will be passed to Siege. |
/* jshint node:true */ | ||
/* global describe, it, beforeEach, afterEach, Promise */ | ||
/* global describe, it, beforeEach, afterEach */ | ||
@@ -9,2 +9,3 @@ 'use strict'; | ||
fs = require('fs'), | ||
Promise = require('bluebird'), | ||
@@ -11,0 +12,0 @@ Clock = require('./clock'), |
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
962427
941
105
3
+ Addedbluebird@2.9.14
+ Addedbluebird@2.9.14(transitive)