Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "get-it", | ||
"version": "0.0.1", | ||
"description": "Get it! Get it?", | ||
"main": "index.js", | ||
"version": "0.0.2", | ||
"description": "Generic HTTP request library for node and browsers", | ||
"main": "lib/index.js", | ||
"browser": { | ||
"./src/request/node-request.js": "./src/request/browser-request.js", | ||
"./lib/request/node-request.js": "./lib/request/browser-request.js", | ||
"./src/middleware/progress/node-progress.js": "./src/middleware/progress/browser-progress.js", | ||
"./lib/middleware/progress/node-progress.js": "./lib/middleware/progress/browser-progress.js", | ||
"./src/util/node-shouldRetry.js": "./src/util/browser-shouldRetry.js", | ||
"./lib/util/node-shouldRetry.js": "./lib/util/browser-shouldRetry.js", | ||
"fs": "./test/helpers/noop.js" | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"ci": "npm run coverage && npm run karma && npm run lint", | ||
"clean": "rimraf lib .nyc_output coverage npm-debug.log yarn-debug.log", | ||
"coverage": "nyc --reporter=html --reporter=lcov --reporter=text _mocha", | ||
"karma": "karma start", | ||
"lint": "eslint .", | ||
"posttest": "npm run lint", | ||
"test": "mocha" | ||
}, | ||
"author": "Espen Hovlandsdal <espen@hovlandsdal.com>", | ||
"license": "MIT" | ||
"keywords": [ | ||
"request", | ||
"http", | ||
"fetch" | ||
], | ||
"author": "Sanity.io <hello@sanity.io>", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@rexxars/timed-out": "^3.0.1", | ||
"any-observable": "^0.2.0", | ||
"any-promise": "^1.3.0", | ||
"create-error-class": "^3.0.2", | ||
"debug": "^2.3.3", | ||
"follow-redirects": "^1.2.0", | ||
"global": "^4.3.1", | ||
"into-stream": "^3.1.0", | ||
"is-retry-allowed": "^1.1.0", | ||
"is-stream": "^1.1.0", | ||
"nano-pubsub": "^1.0.1", | ||
"object-assign": "^4.1.0", | ||
"parse-headers": "^2.0.1", | ||
"progress-stream": "^1.2.0", | ||
"same-origin": "^0.1.1", | ||
"simple-concat": "^1.0.0", | ||
"unzip-response": "^2.0.1", | ||
"url-parse": "^1.1.7" | ||
}, | ||
"devDependencies": { | ||
"@sanity/observable": "^1.1.0", | ||
"babel-cli": "^6.18.0", | ||
"babel-loader": "^6.2.8", | ||
"babel-preset-es2015": "^6.18.0", | ||
"babel-preset-es2015-node4": "^2.1.0", | ||
"babel-register": "^6.18.0", | ||
"chai": "^3.5.0", | ||
"chai-as-promised": "^6.0.0", | ||
"chai-subset": "^1.3.0", | ||
"eslint": "^3.11.1", | ||
"eslint-config-sanity": "^2.0.1", | ||
"karma": "^1.3.0", | ||
"karma-chrome-launcher": "^2.0.0", | ||
"karma-firefox-launcher": "^1.0.0", | ||
"karma-mocha": "^1.3.0", | ||
"karma-phantomjs-launcher": "^1.0.2", | ||
"karma-sourcemap-loader": "^0.3.7", | ||
"karma-virtualboxany-launcher": "^0.0.6", | ||
"karma-webpack": "^1.8.0", | ||
"lodash.once": "^4.1.1", | ||
"mocha": "^3.2.0", | ||
"nyc": "^10.0.0", | ||
"pinkie-promise": "^2.0.1", | ||
"rimraf": "^2.5.4", | ||
"webpack": "^1.13.3" | ||
} | ||
} |
@@ -1,2 +0,71 @@ | ||
More to come! | ||
# get-it | ||
## Wanted features | ||
* [ ] Developer-friendly assertions that are stripped in production to reduce bundle size and performance | ||
* [ ] Authentication (basic) | ||
* [ ] Stream response middleware? | ||
* [x] Progress upload/download events as middleware (available on observable/eventemitter) | ||
* [x] All HTTP methods supported (obviously) | ||
* [x] Configurable number of retries + "should retry" handler | ||
* [x] Follow redirects (optional) up to limit | ||
* [x] Gzip unwrapping support in node (browser automatically handles this) | ||
* [x] Middleware-ish (like MJ's request lib) | ||
* [x] Node and browser support (XHR), with small browser bundle footprint | ||
* [x] Observable/promise/callback/eventemitter support as middleware (low-level by default) | ||
* [x] Parsing of JSON request/response payloads as middleware | ||
* [x] Send file/buffer/stuff as body, should just work | ||
* [x] Timeouts with errors that are catchable (connect/response as separate in node) | ||
## Options | ||
* `rawBody` - Set to `true` to return the raw value of the response body, instead of a string. *Important note*: The returned body will be different in Node and browser environments. In Node, it will return a `Buffer`, while in browsers it will return an `ArrayBuffer`. | ||
## Middleware | ||
Each middleware is an object of hook => action bindings. They are called in the order they are added to the request instance using `request.use()`. For instance, if you want to always set a certain header on outgoing responses, you could do: | ||
``` | ||
const isAwesome = { | ||
processOptions: options => Object.assign({ | ||
headers: Object.assign({}, options.headers, { | ||
'X-Is-Awesome': 'Absolutely' | ||
}) | ||
}) | ||
} | ||
request.use(isAwesome) | ||
``` | ||
The available hooks, their arguments and expected return values are as following: | ||
### processOptions | ||
Called once a new request is instantiated. Can be used to alter options before they are validated and turned into an actual HTTP request. This hook is used by the `base` middleware, which prefixes the passed URL if it is not an absolute URI already. | ||
Arguments: | ||
1. `options` - Object of request options passed to the request. Should be cloned if modifications are to be performed, to prevent unexpected side-effects. | ||
Should return: Plain object of options to pass on to the rest of the middlewares. | ||
### parseResponse | ||
Called once a response has been received and the response body is ready. | ||
@todo document | ||
## Prior work | ||
This module was inspired by the great work of others: | ||
* [got](https://github.com/sindresorhus/got) | ||
* [simple-get](https://github.com/feross/simple-get) | ||
* [xhr](https://github.com/naugtur/xhr) | ||
* [Axios](https://github.com/mzabriskie/axios/) | ||
* [http-client](https://github.com/mjackson/http-client) | ||
* [request](https://github.com/request/request) | ||
## License | ||
MIT-licensed. See LICENSE. |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
209327
63
1690
2
72
18
25
7
4
+ Added@rexxars/timed-out@^3.0.1
+ Addedany-observable@^0.2.0
+ Addedany-promise@^1.3.0
+ Addedcreate-error-class@^3.0.2
+ Addeddebug@^2.3.3
+ Addedfollow-redirects@^1.2.0
+ Addedglobal@^4.3.1
+ Addedinto-stream@^3.1.0
+ Addedis-retry-allowed@^1.1.0
+ Addedis-stream@^1.1.0
+ Addednano-pubsub@^1.0.1
+ Addedobject-assign@^4.1.0
+ Addedparse-headers@^2.0.1
+ Addedprogress-stream@^1.2.0
+ Addedsame-origin@^0.1.1
+ Addedsimple-concat@^1.0.0
+ Addedunzip-response@^2.0.1
+ Addedurl-parse@^1.1.7
+ Added@rexxars/timed-out@3.0.1(transitive)
+ Addedany-observable@0.2.0(transitive)
+ Addedany-promise@1.3.0(transitive)
+ Addedcapture-stack-trace@1.0.2(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addedcreate-error-class@3.0.2(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addeddom-walk@0.1.2(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
+ Addedfrom2@2.3.0(transitive)
+ Addedglobal@4.4.0(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedinto-stream@3.1.0(transitive)
+ Addedis-retry-allowed@1.2.0(transitive)
+ Addedis-stream@1.1.0(transitive)
+ Addedisarray@0.0.11.0.0(transitive)
+ Addedmin-document@2.19.0(transitive)
+ Addedms@2.0.0(transitive)
+ Addednano-pubsub@1.0.2(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedobject-keys@0.4.0(transitive)
+ Addedp-is-promise@1.1.0(transitive)
+ Addedparse-headers@2.0.5(transitive)
+ Addedprocess@0.11.10(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedprogress-stream@1.2.0(transitive)
+ Addedquerystringify@2.2.0(transitive)
+ Addedreadable-stream@1.1.142.3.8(transitive)
+ Addedrequires-port@1.0.0(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedsame-origin@0.1.1(transitive)
+ Addedsimple-concat@1.0.1(transitive)
+ Addedspeedometer@0.1.4(transitive)
+ Addedstring_decoder@0.10.311.1.1(transitive)
+ Addedthrough2@0.2.3(transitive)
+ Addedunzip-response@2.0.1(transitive)
+ Addedurl-parse@1.5.10(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedxtend@2.1.2(transitive)