0.4.1 • Published 6 years ago

@yoctol/axios-logger-mongo v0.4.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

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 } => { /* */ }),
});
0.4.1

6 years ago

0.4.0

6 years ago

0.3.0

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago