<commit_before>var MongoClient = require("mongodb").MongoClient;
var mongoUrl = process.env.MONGODB_URI;
var FileStreamRotator = require("file-stream-rotator");
var express = require("express");
var fs = require("fs");
var morgan = require("morgan");
var path = require("path");
var bodyParser = require("body-parser");

var app = express();
//var accessLogStream = fs.createWriteStream(path.join(__dirname, "log/access.log"), {flags: "a"});
var logDirectory = path.join(__dirname, "log");
fs.existsSync(logDirectory) || fs.mkdirSync(logDirectory);
var accessLogStream = FileStreamRotator.getStream({
  date_format: "YYYYMMDD",
	filename: path.join(logDirectory, "access-%DATE%.log"),
	frequency: "daily",
	verbose: false
});

app.use(morgan("combined", {stream: accessLogStream}));

app.use(bodyParser.json());
app.use("/", express.static("public"));

app.all("/", (req, res, next) => {
	res.header("Access-Control-Allow-Origin", "*");
	res.header("Access-Control-Allow-Headers", "Content-Type");
	next();
});

MongoClient.connect(mongoUrl || "mongodb://mongo:27017/gcmt_dev", function(err, db) {
	if (err) throw err;

	app.post("/quakes", (req, res) => {
		var params = {
			"geometry" : {<commit_msg>Add middleware for HTTP request logging with daily-rotating files<commit_after>var MongoClient = require("mongodb").MongoClient;
var mongoUrl = process.env.MONGODB_URI;
var FileStreamRotator = require("file-stream-rotator");
var express = require("express");
var fs = require("fs");
var morgan = require("morgan");
var path = require("path");
var bodyParser = require("body-parser");

var app = express();

var logDirectory = path.join(__dirname, "log");
fs.existsSync(logDirectory) || fs.mkdirSync(logDirectory);
var accessLogStream = FileStreamRotator.getStream({
  date_format: "YYYYMMDD",
	filename: path.join(logDirectory, "access-%DATE%.log"),
	frequency: "daily",
	verbose: false
});

app.use(morgan("combined", {stream: accessLogStream}));

app.use(bodyParser.json());
app.use("/", express.static("public"));

app.all("/", (req, res, next) => {
	res.header("Access-Control-Allow-Origin", "*");
	res.header("Access-Control-Allow-Headers", "Content-Type");
	next();
});

MongoClient.connect(mongoUrl || "mongodb://mongo:27017/gcmt_dev", function(err, db) {
	if (err) throw err;

	app.post("/quakes", (req, res) => {
		var params = {
			"geometry" : {
{'fraction_non_alphanumeric': 0.1924544298431539, 'fraction_numerical': 0.00423908435777872, 'mean_word_length': 6.108433734939759, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '868755', 'n_tokens_mistral': 809, 'n_tokens_neox': 785, 'n_words': 160}