All Projects → delirius325 → axios-curlirize

delirius325 / axios-curlirize

Licence: MIT license
axios plugin converting requests to cURL commands, saving and logging them.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to axios-curlirize

Cocoadebug
iOS Debugging Tool 🚀
Stars: ✭ 3,769 (+2379.61%)
Mutual labels:  debugging, log, debug
Httpie
As easy as /aitch-tee-tee-pie/ 🥧 Modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more. https://twitter.com/httpie
Stars: ✭ 53,052 (+34802.63%)
Mutual labels:  debugging, curl
Cli Debugging Cheatsheets
🔥 Collection of command-line debugging cheatsheets for multiple languages and runtimes
Stars: ✭ 239 (+57.24%)
Mutual labels:  debugging, debug
clrprint
Print colorful output in the terminal, idle, cmd, and Windows PowerShell using the same functions.
Stars: ✭ 22 (-85.53%)
Mutual labels:  debugging, debug
Icecream
🍦 Never use print() to debug again.
Stars: ✭ 5,601 (+3584.87%)
Mutual labels:  debugging, debug
Bugsnag Ruby
Bugsnag error monitoring & reporting software for rails, sinatra, rack and ruby
Stars: ✭ 211 (+38.82%)
Mutual labels:  debugging, debug
debugging-async-operations-in-nodejs
Example code to accompany my blog post on debugging async operations in Node.js.
Stars: ✭ 22 (-85.53%)
Mutual labels:  debugging, debug
Gdb Frontend
☕ GDBFrontend is an easy, flexible and extensionable gui debugger.
Stars: ✭ 2,104 (+1284.21%)
Mutual labels:  debugging, debug
debug
A tiny JavaScript debugging utility modelled after Node.js core's debugging technique. Works in Node.js and web browsers
Stars: ✭ 10,554 (+6843.42%)
Mutual labels:  debugging, debug
bugsnag-java
Bugsnag error reporting for Java.
Stars: ✭ 51 (-66.45%)
Mutual labels:  debugging, debug
bugsnag-vue
[DEPRECATED] This package now lives within the monorepo for our Universal JS notifier "@bugsnag/js" • https://github.com/bugsnag/bugsnag-js
Stars: ✭ 26 (-82.89%)
Mutual labels:  debugging, debug
Godbg
Go implementation of the Rust `dbg` macro
Stars: ✭ 172 (+13.16%)
Mutual labels:  debugging, debug
Scyllahide
Advanced usermode anti-anti-debugger. Forked from https://bitbucket.org/NtQuery/scyllahide
Stars: ✭ 2,211 (+1354.61%)
Mutual labels:  debugging, debug
Icecream Cpp
🍦 Never use cout/printf to debug again
Stars: ✭ 225 (+48.03%)
Mutual labels:  debugging, debug
Debug Bundle
The DebugBundle allows greater integration of the VarDumper component in the Symfony full-stack framework.
Stars: ✭ 2,033 (+1237.5%)
Mutual labels:  debugging, debug
gdbundle
Minimalist plugin manager for GDB and LLDB
Stars: ✭ 72 (-52.63%)
Mutual labels:  debugging, debug
ducky
Chrome extension to overlay a (super adorable) rubber duck, as a virtual companion during rubber duck debugging.
Stars: ✭ 80 (-47.37%)
Mutual labels:  debugging, debug
Blender Debugger For Vscode
Blender addon for remote debugging Blender with VS Code (and Visual Studio)
Stars: ✭ 123 (-19.08%)
Mutual labels:  debugging, debug
Android Remote Debugger
A library for remote logging, database debugging, shared preferences and network requests
Stars: ✭ 132 (-13.16%)
Mutual labels:  debugging, debug
krumo
Krumo: Structured information display solution for PHP
Stars: ✭ 74 (-51.32%)
Mutual labels:  debugging, debug

Codacy Badge CircleCI npm version

Versions

  • 2.0.0 - Uses ES Native Modules
  • 1.3.7 - Uses CommonJS Modules

Description

This module is an axios third-party module to log any axios request as a curl command in the console. It was originally posted as a suggestion on the axios repository, but since we believed it wasn't in the scope of axios to release such feature, we decided to make it as an independent module.

How it works

The module makes use of axios' interceptors to log the request as a cURL command. It also stores it in the response's config object. Therefore, the command can be seen in the app's console, as well as in the res.config.curlCommand property of the response.

How to use it

axios-curlirize is super easy to use. First you'll have to install it.

npm i --save axios-curlirize@latest

Then all you have to do is import and instanciate curlirize in your app. Here's a sample:

import axios from 'axios';
import express from 'express';
import curlirize from 'axios-curlirize';

const app = express();

// initializing axios-curlirize with your axios instance
curlirize(axios);

// creating dummy route
app.post('/', (req, res) => {
  res.send({ hello: 'world!' });
});

// starting server
app.listen(7500, () => {
  console.log('Dummy server started on port 7500');
  /*
             The output of this in the console will be :
             curl -X POST -H "Content-Type:application/x-www-form-urlencoded" --data {"dummy":"data"} http://localhost:7500/
        */
  axios
    .post('http://localhost:7500/', { dummy: 'data' })
    .then(res => {
      console.log('success');
    })
    .catch(err => {
      console.log(err);
    });
});

Features

Changing the logger

By default, axios-curlirize uses the console.log/error() functions. It is possible to change the logger by doing something similar to this:

// when initiating your curlirize instance
curlirize(axios, (result, err) => {
  const { command } = result;
  if (err) {
    // use your logger here
  } else {
    // use your logger here
  }
});

Curilirize additional axios instance

To curlirize any other instances of axios (aside from the base one), please call the curlirize() method on that instance.

const instance = axios.create({ baseURL: 'https://some-domain.com/api/', timeout: 1000, headers: {'X-Custom-Header': 'foobar'} });
curlirize(instance);

Disable the logger

By default, all requests will be logged. But you can disable this behaviour unitarily by setting the curlirize option to false within the axios request.

axios
  .post('http://localhost:7500/', { dummy: 'data' }, {
    curlirize: false
  })
  .then(res => {
    console.log('success');
  })
  .catch(err => {
    console.log(err);
  });

Clear a request

axios
  .post('http://localhost:7500/', { dummy: 'data' })
  .then(res => {
    res.config.clearCurl();
  })
  .catch(err => {
    console.log(err);
  });
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].