2.2.1 • Published 6 years ago

tr4ffic v2.2.1

Weekly downloads
6
License
ISC
Repository
-
Last release
6 years ago

Tr4ffic

Simple node module for measuring bandwith of your express.js app

Tr4ffic

How to use

You can simply install the node package with npm

npm install tr4ffic

and use it inside your express application like this

var express = require('express');
var app = express();
var tr4ffic = require('tr4ffic');

app.use(tr4ffic);

tr4ffic.on('ingoing', function(bytes){

  console.log("IN " + bytes);

});

tr4ffic.on('outgoing', function(bytes){

  console.log("OUT" + bytes);

});

app.get('/', function(req, res) {

  res.send('We sended ' tr4ffic.get('outgoing') + ' bytes and received ' + tr4ffic.get('ingoing') + "bytes")

});

app.listen(8000);

Events

You can use events in your application for measuring your ingoing and outgoing bandwith. The events are fired by every express request that was made.

tr4ffic.on('ingoing', function(bytes){

  console.log("IN " + bytes);

});

tr4ffic.on('outgoing', function(bytes){

  console.log("OUT" + bytes);

});

Functions

If you want to get the bandwidth usage since the express server was started you can use the functions

tr4ffic.get('outgoing');

or

tr4ffic.get('ingoing')

You also can reset the bandwith usage

tr4ffic.reset('outgoing');

or

tr4ffic.reset('ingoing')
2.2.1

6 years ago

2.1.1

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago