Socket
Book a DemoInstallSign in
Socket

@yoctol/axios-logger-mongo

Package Overview
Dependencies
Maintainers
6
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yoctol/axios-logger-mongo

Mongo logger interceptor for Axios.

latest
Source
npmnpm
Version
0.4.1
Version published
Weekly downloads
4
Maintainers
6
Weekly downloads
 
Created
Source

axios-logger-mongo

npm

Mongo logger interceptor for Axios.

Installation

Install using npm:

npm install @yoctol/axios-logger-mongo

API Reference

ParamType
mongoURLStringURL of the mongodb.
collectionNameStringName of the collection.
allInstancesBooleanSupport all of axios instances or not.
transformRequestBodyFunctionFunction to map request body.
transformResponseBodyFunctionFunction to map response body.

Usage

const { useMongoLogger } = require('@yoctol/axios-logger-mongo');

useMongoLogger(axios, {
  mongoURL: 'mongodb://localhost:27017/',
  collectionName: 'logs',
});

To support all of axios instances, set option allInstances to true:

useMongoLogger(axios, {
  mongoURL: 'mongodb://localhost:27017/',
  collectionName: 'logs',
  allInstances: true,
});

To transform your request, response before saving to database, use transformRequestBody or transformResponseBody:

useMongoLogger(axios, {
  mongoURL: 'mongodb://localhost:27017/',
  collectionName: 'logs',
  transformRequestBody: (body, { request, config } => { /* */ }),
  transformResponseBody: (body, { response, config } => { /* */ }),
});

Keywords

axios

FAQs

Package last updated on 16 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts