Skip to content

Instantly share code, notes, and snippets.

@freakynit
Created August 25, 2016 15:24
Show Gist options
  • Select an option

  • Save freakynit/b1efcf9259e5ef702f858c299e7898a5 to your computer and use it in GitHub Desktop.

Select an option

Save freakynit/b1efcf9259e5ef702f858c299e7898a5 to your computer and use it in GitHub Desktop.
var PORT = 9999;
var express = require('express');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.all("*", function(req, res, next){
console.log("===================== New request =====================");
console.log("Body: " + JSON.stringify(req.body));
console.log("Query: " + JSON.stringify(req.query));
console.log("Params: " + JSON.stringify(req.params));
console.log("Headers: " + JSON.stringify(req.headers));
console.log("\n\n");
res.json({"status": "success"});
});
app.listen(PORT);
{
"name": "request_logger",
"version": "1.0.0",
"description": "",
"main": "app.js",
"dependencies": {
"body-parser": "^1.15.2",
"cookie-parser": "^1.4.3",
"express-logging": "^1.1.1",
"logops": "^1.0.5",
"express": "^4.14.0"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Nitin Bansal <[email protected]> (http://webengage.com)",
"license": "ISC"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment