axios-debug-log
Advanced tools
Comparing version 0.6.2 to 0.7.0
import { AxiosInstance, AxiosRequestConfig, AxiosResponse, AxiosError } from "axios"; | ||
import { Debugger } from "debug"; | ||
interface UserOptions { | ||
declare interface UserOptions { | ||
request(debug: Debugger, config: AxiosRequestConfig): void; | ||
@@ -10,3 +10,6 @@ response(debug: Debugger, response: AxiosResponse): void; | ||
export default function(userOptions: UserOptions): void; | ||
export function addLogger(instance: AxiosInstance, debug: Debugger): void; | ||
declare const config: ((userOptions: UserOptions) => void) & { | ||
addLogger(instance: AxiosInstance, debug: Debugger): void; | ||
} | ||
export = config; |
22
index.js
'use strict' | ||
var axios = require('axios') | ||
var isAbsoluteURL = require('axios/lib/helpers/isAbsoluteURL') | ||
var buildURL = require('axios/lib/helpers/buildURL') | ||
var combineURLs = require('axios/lib/helpers/combineURLs') | ||
var axiosDebug = require('debug')('axios') | ||
const getURL = (config) => { | ||
return buildURL(config.url, config.params, config.paramsSerializer) | ||
var URL_KEY = '__AXIOS-DEBUG-LOG_URL__' | ||
function getURL (config) { | ||
var url = config.url | ||
if (config.baseURL && !isAbsoluteURL(url)) { | ||
url = combineURLs(config.baseURL, url) | ||
} | ||
return buildURL(url, config.params, config.paramsSerializer) | ||
} | ||
@@ -13,10 +21,13 @@ | ||
request: function (debug, config) { | ||
var url = getURL(config) | ||
Object.defineProperty(config, URL_KEY, { value: url }) | ||
debug( | ||
config.method.toUpperCase() + ' ' + getURL(config) | ||
config.method.toUpperCase() + ' ' + url | ||
) | ||
}, | ||
response: function (debug, response) { | ||
var url = response.config[URL_KEY] | ||
debug( | ||
response.status + ' ' + response.statusText, | ||
'(' + response.config.method.toUpperCase() + ' ' + getURL(response.config) + ')' | ||
'(' + response.config.method.toUpperCase() + ' ' + url + ')' | ||
) | ||
@@ -26,5 +37,6 @@ }, | ||
if (error.config) { | ||
var url = error.config[URL_KEY] | ||
debug( | ||
error.name + ': ' + error.message, | ||
'(' + error.config.method.toUpperCase() + ' ' + getURL(error.config) + ')' | ||
'(' + error.config.method.toUpperCase() + ' ' + url + ')' | ||
) | ||
@@ -31,0 +43,0 @@ } else { |
{ | ||
"name": "axios-debug-log", | ||
"version": "0.6.2", | ||
"version": "0.7.0", | ||
"description": "Axios interceptor of logging requests & responses by debug.", | ||
"main": "index.js", | ||
"files": [ | ||
"index.js", | ||
"index.d.ts" | ||
], | ||
"scripts": { | ||
"lint": "standard", | ||
"typing": "tsc", | ||
"test": "mocha --require should --require should-sinon", | ||
"coverage": "nyc npm test && nyc report --reporter=html" | ||
"test": "mocha", | ||
"coverage": "nyc mocha", | ||
"postcoverage": "nyc report --reporter=html" | ||
}, | ||
@@ -32,14 +37,14 @@ "repository": { | ||
"devDependencies": { | ||
"axios": ">=0.13.0", | ||
"mocha": "^6.1.4", | ||
"nyc": "^14.0.0", | ||
"axios": ">=0.17.0", | ||
"mocha": "^7.0.1", | ||
"nyc": "^15.0.0", | ||
"should": "^13.1.3", | ||
"should-sinon": "0.0.6", | ||
"sinon": "^7.1.1", | ||
"standard": "^12.0.0", | ||
"sinon": "^9.0.0", | ||
"standard": "^14.0.0", | ||
"typescript": "^3.5.1" | ||
}, | ||
"peerDependencies": { | ||
"axios": ">=0.13.0" | ||
"axios": ">=0.17.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
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
7963
5
82
1