Comparing version 2.0.1 to 2.1.0
/// <reference types="node" /> | ||
import { AbortSignal } from 'abort-controller'; | ||
import { Agent } from 'https'; | ||
import { Agent } from 'http'; | ||
import { URL } from 'url'; | ||
export declare class GaxiosError<T = any> extends Error { | ||
@@ -53,3 +54,3 @@ code?: string; | ||
responseType?: 'arraybuffer' | 'blob' | 'json' | 'text' | 'stream'; | ||
agent?: Agent; | ||
agent?: Agent | ((parsedUrl: URL) => Agent); | ||
validateStatus?: (status: number) => boolean; | ||
@@ -56,0 +57,0 @@ retryConfig?: RetryConfig; |
@@ -18,2 +18,7 @@ import { GaxiosOptions, GaxiosPromise } from './common'; | ||
request<T = any>(opts?: GaxiosOptions): GaxiosPromise<T>; | ||
/** | ||
* Internal, retryable version of the `request` method. | ||
* @param opts Set of HTTP options that will be used for this HTTP request. | ||
*/ | ||
private _request; | ||
private getResponseData; | ||
@@ -35,4 +40,3 @@ /** | ||
private paramsSerializer; | ||
private isReadableStream; | ||
private translateResponse; | ||
} |
@@ -21,10 +21,18 @@ "use strict"; | ||
const querystring_1 = __importDefault(require("querystring")); | ||
const stream_1 = __importDefault(require("stream")); | ||
const is_stream_1 = __importDefault(require("is-stream")); | ||
const url_1 = __importDefault(require("url")); | ||
const common_1 = require("./common"); | ||
const isbrowser_1 = require("./isbrowser"); | ||
const retry_1 = require("./retry"); | ||
// tslint:disable no-any | ||
const URL = isbrowser_1.isBrowser() ? window.URL : url_1.default.URL; | ||
const fetch = isbrowser_1.isBrowser() ? window.fetch : node_fetch_1.default; | ||
const URL = hasURL() ? window.URL : url_1.default.URL; | ||
const fetch = hasFetch() ? window.fetch : node_fetch_1.default; | ||
function hasWindow() { | ||
return typeof window !== 'undefined' && !!window; | ||
} | ||
function hasURL() { | ||
return hasWindow() && !!window.URL; | ||
} | ||
function hasFetch() { | ||
return hasWindow() && !!window.fetch; | ||
} | ||
// tslint:disable-next-line variable-name | ||
@@ -60,2 +68,9 @@ let HttpsProxyAgent; | ||
opts = this.validateOpts(opts); | ||
return this._request(opts); | ||
} | ||
/** | ||
* Internal, retryable version of the `request` method. | ||
* @param opts Set of HTTP options that will be used for this HTTP request. | ||
*/ | ||
async _request(opts = {}) { | ||
try { | ||
@@ -82,3 +97,3 @@ let translatedResponse; | ||
err.config.retryConfig.currentRetryAttempt = config.retryConfig.currentRetryAttempt; | ||
return this.request(err.config); | ||
return this._request(err.config); | ||
} | ||
@@ -138,3 +153,3 @@ throw err; | ||
if (opts.data) { | ||
if (this.isReadableStream(opts.data)) { | ||
if (is_stream_1.default.readable(opts.data)) { | ||
opts.body = opts.data; | ||
@@ -182,5 +197,2 @@ } | ||
} | ||
isReadableStream(obj) { | ||
return obj instanceof stream_1.default.Readable && typeof obj._read === 'function'; | ||
} | ||
translateResponse(opts, res, data) { | ||
@@ -187,0 +199,0 @@ // headers need to be converted from a map to an obj |
{ | ||
"name": "gaxios", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"description": "A simple common HTTP client specifically for Google APIs and services.", | ||
@@ -12,14 +12,17 @@ "main": "build/src/index.js", | ||
"lint": "gts check", | ||
"test": "nyc mocha build/test", | ||
"test": "c8 mocha build/test", | ||
"presystem-test": "npm run compile", | ||
"system-test": "mocha build/system-test --timeout 40000", | ||
"clean": "gts clean", | ||
"compile": "tsc -p . && npm run fix", | ||
"compile": "tsc -p .", | ||
"fix": "gts fix", | ||
"prepare": "npm run compile", | ||
"pretest": "npm run compile", | ||
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json", | ||
"webpack": "webpack", | ||
"prebrowser-test": "npm run compile", | ||
"browser-test": "node build/browser-test/browser-test-runner.js" | ||
"browser-test": "node build/browser-test/browser-test-runner.js", | ||
"docs": "compodoc src/", | ||
"docs-test": "linkinator docs", | ||
"predocs-test": "npm run docs", | ||
"samples-test": "cd samples/ && npm link ../ && npm test && cd ../" | ||
}, | ||
@@ -31,3 +34,3 @@ "repository": "JustinBeckwith/gaxios", | ||
"engines": { | ||
"node": ">=8" | ||
"node": ">=8.10.0" | ||
}, | ||
@@ -37,4 +40,5 @@ "author": "Google, LLC", | ||
"devDependencies": { | ||
"@compodoc/compodoc": "^1.1.9", | ||
"@types/execa": "^0.9.0", | ||
"@types/express": "^4.16.1", | ||
"@types/execa": "^0.9.0", | ||
"@types/extend": "^3.0.1", | ||
@@ -44,3 +48,3 @@ "@types/mocha": "^5.2.6", | ||
"@types/ncp": "^2.0.1", | ||
"@types/nock": "^9.3.1", | ||
"@types/nock": "^10.0.0", | ||
"@types/node": "^11.9.5", | ||
@@ -51,10 +55,11 @@ "@types/node-fetch": "^2.1.6", | ||
"assert-rejects": "^1.0.0", | ||
"c8": "^5.0.1", | ||
"codecov": "^3.2.0", | ||
"execa": "^3.0.0", | ||
"express": "^4.16.4", | ||
"execa": "^1.0.0", | ||
"gts": "^1.0.0", | ||
"is-docker": "^2.0.0", | ||
"karma": "^4.0.0", | ||
"karma-chrome-launcher": "^2.2.0", | ||
"karma-coverage": "^1.1.2", | ||
"karma-chrome-launcher": "^3.0.0", | ||
"karma-coverage": "^2.0.0", | ||
"karma-firefox-launcher": "^1.1.0", | ||
@@ -64,16 +69,15 @@ "karma-mocha": "^1.3.0", | ||
"karma-sourcemap-loader": "^0.3.7", | ||
"karma-webpack": "^3.0.5", | ||
"karma-webpack": "^4.0.0", | ||
"linkinator": "^1.5.0", | ||
"mocha": "^6.0.2", | ||
"mv": "^2.1.1", | ||
"ncp": "^2.0.0", | ||
"nock": "^10.0.6", | ||
"null-loader": "^1.0.0", | ||
"nyc": "^14.0.0", | ||
"nock": "^11.0.0", | ||
"null-loader": "^3.0.0", | ||
"puppeteer": "^1.12.2", | ||
"semantic-release": "^15.13.9", | ||
"sinon": "^7.2.5", | ||
"source-map-support": "^0.5.10", | ||
"tmp": "0.1.0", | ||
"ts-loader": "^5.3.3", | ||
"typescript": "~3.4.0", | ||
"ts-loader": "^6.0.0", | ||
"typescript": "~3.6.0", | ||
"webpack": "^4.29.5", | ||
@@ -85,10 +89,6 @@ "webpack-cli": "^3.2.3" | ||
"extend": "^3.0.2", | ||
"https-proxy-agent": "^2.2.1", | ||
"https-proxy-agent": "^3.0.0", | ||
"is-stream": "^2.0.0", | ||
"node-fetch": "^2.3.0" | ||
}, | ||
"nyc": { | ||
"exclude": [ | ||
"build/test" | ||
] | ||
} | ||
} |
# gaxios | ||
[![npm version](https://img.shields.io/npm/v/gaxios.svg)](https://www.npmjs.org/package/gaxios) | ||
[![Build Status](https://api.cirrus-ci.com/github/JustinBeckwith/gaxios.svg)](https://cirrus-ci.com/github/JustinBeckwith/gaxios) | ||
[![codecov](https://codecov.io/gh/JustinBeckwith/gaxios/branch/master/graph/badge.svg)](https://codecov.io/gh/JustinBeckwith/gaxios) | ||
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) | ||
[![codecov](https://codecov.io/gh/googleapis/gaxios/branch/master/graph/badge.svg)](https://codecov.io/gh/googleapis/gaxios) | ||
[![Code Style: Google](https://img.shields.io/badge/code%20style-google-blueviolet.svg)](https://github.com/google/gts) | ||
> An HTTP request client that provides an `axios` like interfance over top of `node-fetch`. Only really useful if you're trying to migrate from axios to the fetch. | ||
> An HTTP request client that provides an `axios` like interface over top of `node-fetch`. | ||
@@ -142,2 +141,2 @@ ## Install | ||
## License | ||
[Apache-2.0](LICENSE) | ||
[Apache-2.0](https://github.com/googleapis/gaxios/blob/master/LICENSE) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
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
49375
19
5
41
552
142
3
+ Addedis-stream@^2.0.0
+ Addedhttps-proxy-agent@3.0.1(transitive)
+ Addedis-stream@2.0.1(transitive)
- Removedhttps-proxy-agent@2.2.4(transitive)
Updatedhttps-proxy-agent@^3.0.0