axios-curlirize
Advanced tools
Comparing version 1.3.7 to 1.4.0
{ | ||
"name": "axios-curlirize", | ||
"version": "1.3.7", | ||
"version": "1.4.0", | ||
"description": "Axios third-party module to print all axios requests as curl commands in the console. This repository is forked from axios-curlirize <https://www.npmjs.com/package/axios-curlirize> and supports use with Node JS without having to enable ES6 imports. This repo was inspired by an issue <https://github.com/delirius325/axios-curlirize/issues/20> raised on the origional repository <https://github.com/delirius325/axios-curlirize>. Special thanks to Anthony Gauthier <https://github.com/delirius325>, the author of axios-curlirize", | ||
"main": "index.js", | ||
"main": "src/main.js", | ||
"type": "module", | ||
"scripts": { | ||
"test": "./node_modules/.bin/babel ./src --experimental --source-maps-inline -d ./dist && export NODE_ENV=test || SET \"NODE_ENV=test\" && mocha --exit dist/test/*.test.js", | ||
"prepare": "if [ -e ./node_modules/.bin/babel ]; then ./node_modules/.bin/babel ./src --experimental --source-maps-inline -d ./dist; fi" | ||
"test": "./node_modules/mocha/bin/mocha --recursive --exit tests/**/*.spec.js*" | ||
}, | ||
@@ -39,13 +39,11 @@ "repository": { | ||
"homepage": "https://github.com/delirius325/axios-curlirize#readme", | ||
"dependencies": {}, | ||
"dependencies": { | ||
}, | ||
"devDependencies": { | ||
"axios": ">=0.19.0", | ||
"babel-cli": "^6.26.0", | ||
"babel-core": "^6.26.0", | ||
"babel-polyfill": "^6.26.0", | ||
"babel-preset-env": "^1.6.1", | ||
"expect": "^23.1.0", | ||
"express": "^4.16.3", | ||
"mocha": "^5.2.0" | ||
"axios": ">=0.21.1", | ||
"eslint": "^7.29.0", | ||
"expect": "^27.0.6", | ||
"express": "^4.17.1", | ||
"mocha": "^9.0.1" | ||
} | ||
} |
@@ -72,2 +72,9 @@ [![Codacy Badge](https://api.codacy.com/project/badge/Grade/7d519058c2f340428a1b7ef22d71368f)](https://app.codacy.com/app/antho325/axios-curlirize?utm_source=github.com&utm_medium=referral&utm_content=delirius325/axios-curlirize&utm_campaign=Badge_Grade_Dashboard) | ||
## Curilirize additional axios instance | ||
To curlirize any other instances of axios (aside from the base one), please call the `curlirize()` method on that instance. | ||
```javascript | ||
const instance = axios.create({ baseURL: 'https://some-domain.com/api/', timeout: 1000, headers: {'X-Custom-Header': 'foobar'} }); | ||
curlirize(instance); | ||
``` | ||
# Disable the logger | ||
@@ -88,2 +95,15 @@ | ||
}); | ||
``` | ||
``` | ||
# Clear a request | ||
```javascript | ||
axios | ||
.post('http://localhost:7500/', { dummy: 'data' }) | ||
.then(res => { | ||
res.config.clearCurl(); | ||
}) | ||
.catch(err => { | ||
console.log(err); | ||
}); | ||
``` |
@@ -16,3 +16,3 @@ export class CurlHelper { | ||
// add any custom headers (defined upon calling methods like .get(), .post(), etc.) | ||
for (let property in this.request.headers) { | ||
for(let property in this.request.headers) { | ||
if ( | ||
@@ -27,5 +27,7 @@ !["common", "delete", "get", "head", "patch", "post", "put"].includes( | ||
for (let property in headers) { | ||
let header = `${property}:${headers[property]}`; | ||
curlHeaders = `${curlHeaders} -H "${header}"`; | ||
for(let property in headers) { | ||
if({}.hasOwnProperty.call(headers, property)) { | ||
let header = `${property}:${headers[property]}`; | ||
curlHeaders = `${curlHeaders} -H "${header}"`; | ||
} | ||
} | ||
@@ -69,8 +71,10 @@ | ||
for (let param in this.request.params) { | ||
params += | ||
i != 0 | ||
for(let param in this.request.params) { | ||
if({}.hasOwnProperty.call(this.request.params, param)) { | ||
params += | ||
i !== 0 | ||
? `&${param}=${this.request.params[param]}` | ||
: `?${param}=${this.request.params[param]}`; | ||
i++; | ||
i++; | ||
} | ||
} | ||
@@ -84,4 +88,4 @@ | ||
if (this.getQueryString() != "") { | ||
url = url.charAt(url.length - 1) == "/" ? url.substr(0, url.length - 1) : url; | ||
if (this.getQueryString() !== "") { | ||
url = url.charAt(url.length - 1) === "/" ? url.substr(0, url.length - 1) : url; | ||
url += this.getQueryString(); | ||
@@ -88,0 +92,0 @@ } |
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
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
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
5
108
Yes
17251
9
311
1
1