{"size": 874, "ext": "js", "max_stars_repo_path": "test_apps/nodejswithmysql/app.js", "max_stars_repo_name": "UhuruSoftware/uhuru-webui", "max_stars_repo_stars_event_min_datetime": "2015-01-19T12:02:09.000Z", "max_stars_repo_stars_event_max_datetime": "2015-01-19T12:02:09.000Z", "max_issues_repo_path": "test_apps/nodejswithmysql/app.js", "max_issues_repo_name": "UhuruSoftware/uhuru-webui", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test_apps/nodejswithmysql/app.js", "max_forks_repo_name": "UhuruSoftware/uhuru-webui", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 23.0, "max_line_length": 79, "alphanum_fraction": 0.5423340961}
require("cf-autoconfig");
var express = require("express");
var app = express();

var check_connection = function(req, res){

    var mysql      = require('mysql');
    var connection = mysql.createConnection();

    connection.connect();

    connection.query('SELECT NOW() as time_now;', function(err, rows, fields) {
        if (err)
        {
            res.writeHead(500, {"Content-Type": "text/plain"});
            res.write(String(err));
            res.end();
        }
        else
        {
            res.writeHead(200, {"Content-Type": "text/plain"});
            res.write(String(rows[0].time_now));
            res.write("OK");
            res.end();
        }

        console.log('The solution is: ' );
    });

    connection.end();
}

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

app.listen(process.env.VCAP_APP_PORT || 3000);
