mongolog
v1.0.0
Published
express middleware for logging http queries to mongoDB
Downloads
5
Maintainers
Readme
Mongolog
Express middleware for logging http queries to mongoDB.
Mongolog
saves data this way:
{
ip: '<clients ip address>',
date: '<short date>',
urls: {
url: '<url to resource>',
count: '<count of requests>'
}
}
Install
npm i mongolog --save
Hot to use?
Mongolog
could be used as express middleware this way.
var mongoLog = require('mongolog'),
express = require('express'),
app = express(),
port = 1337,
ip = '0.0.0.0',
url = 'mongodb://localhost:27017/mongolog';
MongoClient.connect(url, function(error, db) {
if (error) {
console.error(error.message);
} else {
app.use(mongoLog({
db : db,
name: 'mongolog
}));
app.use(express.static(__dirname));
http.createServer(app)
.listen(port, ip);
console.log('url:', ip + ':' + port);
}
});
License
MIT