@apimanager/logger
Logger is a lightning fast NPM package to monitor API Endpoints.
Last updated 3 months ago by timothyverhaeghe .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @apimanager/logger 
SYNC missed versions from official npm registry.

API Logger

NPM package that will monitor & log your API usage. It's very easy to install and will help you discover API improvements, timings & security issues. It's created and used in ProductBuilders' APIManager

Installation

npm install @apimanager/logger --save

Usage

APILogger as (main) middleware

const APILogger = require('@apimanager/logger'); // Import the APILogger package
const express = require('express'); // Import a HTTP server (eg. ExpressJS)

// Create your APP
const app = express();

// Configure your APP to listen to incoming calls
app.use(APILogger.listen({
  domain: 'example.com',
  apiKey: 'xxxxx',
  apiHost: 'YOURAPIHOST'
}));

// Start your application
app.listen(3000, () => {
  console.log('Your app started on port 3000');
});

Or you can use it in a single endpoint

const express = require('express'); // Import a HTTP server (eg. ExpressJS)

// Create your APP
const app = express();

const APILogger = require('@apimanager/logger').listen({
  domain: 'example.com',
  apiKey: 'xxxxx',
  apiHost: 'YOURAPIHOST'
})

// Configure your APP to listen to incoming calls
app.get('/', APILogger, (req, res){
  res.end('Hello world');
});

// Start your application
app.listen(3000, () => {
  console.log('Your app started on port 3000');
});

Important note

We try to optimise this library and our (big data) storage as much as possible. Therefore, we've renamed all the fields to a way smaller format.

The data we store is:

m: String, // Method => GET, PUT, DELETE, POST
u: String, // Url => URL including query params
p: String, // path => The clean path
h: String, // hostname => Blocked if localhost
pr: String, // protocol => HTTP or HTTPS
i: String, // IP address
ua: String, // The user agent
t: Number, // Time it took to response
c: Number, // The official status code
b: Object, // IF POST or Put, the body
ca: Date, // CreatedAt

Possible settings

  • key => Your API key, unique for each project (required)

Contribute

# To publish this package. Do:
npm publish --access public

Roadmap

  • Terminal resize

Copyright

APIManager

Current Tags

  • 1.0.3                                ...           latest (3 months ago)

4 Versions

  • 1.0.3                                ...           3 months ago
  • 1.0.2                                ...           3 months ago
  • 1.0.1                                ...           3 months ago
  • 1.0.0                                ...           3 months ago
Maintainers (1)
Downloads
Today 0
This Week 4
This Month 8
Last Day 4
Last Week 0
Last Month 0
Dependencies (4)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |