cached-request
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -222,3 +222,2 @@ /* | ||
//Read the response file | ||
var responseBody; | ||
stream.on("data", function (data) { | ||
@@ -225,0 +224,0 @@ //Write to the response |
{ | ||
"name": "cached-request", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Node.js module to perform HTTP requests with caching support", | ||
@@ -27,5 +27,5 @@ "author": "Daniel López <danypype@gmail.com>", | ||
"devDependencies": { | ||
"chai": "^1.10.0", | ||
"mocha": "^2.1.0", | ||
"nock": "^0.52.4", | ||
"chai": "^4.0.2", | ||
"mocha": "^3.4.2", | ||
"nock": "^9.0.13", | ||
"request": "^2.51.0", | ||
@@ -32,0 +32,0 @@ "temp": "^0.8.1" |
@@ -1,8 +0,10 @@ | ||
#cached-request | ||
[![Build Status](https://travis-ci.org/alltherooms/cached-request.svg?branch=master)](https://travis-ci.org/alltherooms/cached-request) | ||
# cached-request | ||
Node.js module to perform HTTP requests with caching support. | ||
##Why? | ||
## Why? | ||
At [alltherooms](http://alltherooms.com/) we make lots of requests to external APIs, and caching is crucial to provide a good experience to our users. We also love streams! however, we had a hard time finding a good tool for caching HTTP responses and streaming them at the same time, so we wrote **cached-request**. We hope to help others, and feedback is always welcome. :) | ||
##How it works | ||
## How it works | ||
This tool was made to work with the popular [request](https://github.com/request/request) module, which simplifies the HTTP requests in Node.js. Therefore, this must be considered a wrapper around **request**. | ||
@@ -16,3 +18,3 @@ | ||
##Installation | ||
## Installation | ||
Install it using [npm](https://www.npmjs.com/) | ||
@@ -23,3 +25,3 @@ ``` | ||
##Usage | ||
## Usage | ||
First, you must set it up: | ||
@@ -37,3 +39,3 @@ ```javascript | ||
###Passing a callback | ||
### Passing a callback | ||
```javascript | ||
@@ -48,3 +50,3 @@ cachedRequest(options, function (error, response, body) { | ||
###As a stream | ||
### As a stream | ||
``` | ||
@@ -54,3 +56,3 @@ cachedRequest(options).pipe(someWriteStream); | ||
##request options | ||
## request options | ||
When making a request, you must pass an `options` object as you can observe in the examples above. This object can contain any of the [options supported by **request**](https://github.com/request/request#requestoptions-callback) with the addition of a required `ttl` option. | ||
@@ -75,6 +77,6 @@ | ||
##Can I use everything that comes with **request**? | ||
## Can I use everything that comes with **request**? | ||
No, there's some things you can't use. For example, the shortcut functions `.get`, `.post`, `.put`, etc. are not available in **cached-request**. If you'd like to have them, this is a great opportunity to contribute! | ||
##Running tests | ||
## Running tests | ||
Run the tests with npm | ||
@@ -85,2 +87,2 @@ ``` | ||
##License (MIT) | ||
## License (MIT) |
@@ -183,3 +183,3 @@ var CachedRequest = require("../") | ||
if (this._parseHeaders) { | ||
this.cachedRequest.set('parseHeaders', this._parseHeaders); | ||
this.cachedRequest.setValue('parseHeaders', this._parseHeaders); | ||
} | ||
@@ -202,4 +202,4 @@ }); | ||
self._parseHeaders = self.cachedRequest.get('parseHeaders'); | ||
self.cachedRequest.set('parseHeaders', function () { | ||
self._parseHeaders = self.cachedRequest.getValue('parseHeaders'); | ||
self.cachedRequest.setValue('parseHeaders', function () { | ||
throw new Error('Cannot parse headers'); | ||
@@ -206,0 +206,0 @@ }); |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
27805
12
82
0
659