Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

axios-debug-log

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

axios-debug-log - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

13

index.js
'use strict'
var axios = require('axios')
var buildURL = require('axios/lib/helpers/buildURL')
var axiosDebug = require('debug')('axios')
const getURL = (config) => {
return buildURL(config.url, config.params, config.paramsSerializer)
}
var options = {
request: function (debug, config) {
debug(config.method.toUpperCase() + ' ' + config.url)
debug(
config.method.toUpperCase() + ' ' + getURL(config)
)
},

@@ -13,3 +20,3 @@ response: function (debug, response) {

response.status + ' ' + response.statusText,
'(' + response.config.method.toUpperCase() + ' ' + response.config.url + ')'
'(' + response.config.method.toUpperCase() + ' ' + getURL(response.config) + ')'
)

@@ -21,3 +28,3 @@ },

error.name + ': ' + error.message,
'(' + error.config.method.toUpperCase() + ' ' + error.config.url + ')'
'(' + error.config.method.toUpperCase() + ' ' + getURL(error.config) + ')'
)

@@ -24,0 +31,0 @@ } else {

{
"name": "axios-debug-log",
"version": "0.4.0",
"version": "0.5.0",
"description": "Axios interceptor of logging requests & responses by debug.",

@@ -21,3 +21,3 @@ "main": "index.js",

],
"author": "George Chung <Gerhut@GMail.com>",
"author": "George Cheng <Gerhut@GMail.com>",
"license": "BSD-3-Clause",

@@ -29,12 +29,12 @@ "bugs": {

"dependencies": {
"debug": "^3.0.0"
"debug": "^4.0.0"
},
"devDependencies": {
"axios": ">=0.13.0",
"mocha": "^3.2.0",
"nyc": "^11.0.2",
"should": "^13.0.0",
"mocha": "^6.1.4",
"nyc": "^14.0.0",
"should": "^13.1.3",
"should-sinon": "0.0.6",
"sinon": "^4.0.0",
"standard": "^10.0.2"
"sinon": "^7.1.1",
"standard": "^12.0.0"
},

@@ -41,0 +41,0 @@ "peerDependencies": {

@@ -49,2 +49,19 @@ /* eslint-env mocha */

it('should log query params of request in error', () => axios({
method: 'FOO',
url: 'http://example.com/',
params: {
name: 'value'
},
adapter: config => Promise.reject(Object.assign(TypeError('Boom'), { config }))
}).catch(() => {
debug.log.should.be.calledTwice()
debug.log.firstCall.should.be.calledWithExactly(
'FOO http://example.com/?name=value'
)
debug.log.secondCall.should.be.calledWithExactly(
'TypeError: Boom', '(FOO http://example.com/?name=value)'
)
}))
it('should log general error', () => axios({

@@ -82,2 +99,91 @@ method: 'FOO',

it('should log params of the request of axios instance', () => axios.create()({
method: 'GET',
url: 'http://example.com/',
params: {
name: 'value'
},
adapter: config => Promise.resolve({
status: 200,
statusText: 'BAR',
config
})
}).then(() => {
debug.log.should.be.calledTwice()
debug.log.firstCall.should.be.calledWithExactly(
'GET http://example.com/?name=value'
)
debug.log.secondCall.should.be.calledWithExactly(
'200 BAR', '(GET http://example.com/?name=value)'
)
}))
it('should use axios default params when logging the URL', () => axios.create({
params: {
foo: 'bar'
},
paramsSerializer: params => {
const querystring = require('querystring')
return querystring.encode(params) + '&baz=qux'
}
})({
method: 'GET',
url: 'http://example.com/',
adapter: config => Promise.resolve({
status: 200,
statusText: 'BAR',
config
})
}).then(() => {
debug.log.should.be.calledTwice()
debug.log.firstCall.should.be.calledWithExactly(
'GET http://example.com/?foo=bar&baz=qux'
)
debug.log.secondCall.should.be.calledWithExactly(
'200 BAR', '(GET http://example.com/?foo=bar&baz=qux)'
)
}))
it('should log params from both the url and the params of the request', () => axios.create()({
method: 'GET',
url: 'http://example.com/?foo=bar',
params: {
name: 'value'
},
adapter: config => Promise.resolve({
status: 200,
statusText: 'BAR',
config
})
}).then(() => {
debug.log.should.be.calledTwice()
debug.log.firstCall.should.be.calledWithExactly(
'GET http://example.com/?foo=bar&name=value'
)
debug.log.secondCall.should.be.calledWithExactly(
'200 BAR', '(GET http://example.com/?foo=bar&name=value)'
)
}))
it('should log params of the request of axios instance with special characters', () => axios.create()({
method: 'GET',
url: 'http://example.com/',
params: {
'parameter name': '&'
},
adapter: config => Promise.resolve({
status: 200,
statusText: 'BAR',
config
})
}).then(() => {
debug.log.should.be.calledTwice()
debug.log.firstCall.should.be.calledWithExactly(
'GET http://example.com/?parameter+name=%26'
)
debug.log.secondCall.should.be.calledWithExactly(
'200 BAR', '(GET http://example.com/?parameter+name=%26)'
)
}))
it('should add custom debug logger to axios instance', () => {

@@ -84,0 +190,0 @@ const spy = sinon.spy()

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc