<commit_before>var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var io = require('socket.io');
var mysql = require('mysql');

var routes = require('./routes/index');
var users = require('./routes/users');

var app = express();
var server = require('http').createServer(app);
var io = io.listen(server);

// connect mysql data base 
var connection = mysql.createConnection({
	host: process.env.DB_HOST || 'localhost',
	user : 'mod1_user',
	password: process.<PASSWORD>.DB_PASS || '<PASSWORD>',
	database: process.env.DB_NAME || 'mod1_DB'
});

var connect_message = {
	"name" : "NodejsServer",
	"message" : "Success Connection"
};

// Catch data from Database and output console
connection.query('select * from messages', function(err, results, fields){
	console.log('---results---');
	console.log(results);
	console.log('---result end---');
	console.log('---fields---');
	console.log(fields);
	console.log('---fields end---');
});

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');

// uncomment after placing your favicon in /public
app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.use('/', routes);
app.use('/users', users);

// catch 404 and forward to error handler
app.use(function(req, res, next) {
    var err = new Error('Not Found');
    err.status = 404;
    next(err);
});

//--- Error Handlers ---//

// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
    app.use(function(err, req, res, next) {
        res.status(err.status || 500);
        res.render('error', {
            message: err.message,
            error: err
        });
    });
}

// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
    res.status(err.status || 500);
    res.render('error', {
        message: err.message,
        error: {}
    });
});

//--- End Error Handlers ---//

// listen server
server.listen(3000);
console.log('server is listening on port 3000');

//--- Socket.IO ---//
<commit_msg>comment out app.listen on app.js<commit_after>var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var io = require('socket.io');
var mysql = require('mysql');

var routes = require('./routes/index');
var users = require('./routes/users');

var app = express();
var server = require('http').createServer(app);
var io = io.listen(server);

// connect mysql data base 
var connection = mysql.createConnection({
	host: process.env.DB_HOST || 'localhost',
	user : 'mod1_user',
	password: process.env.DB_PASS || '<PASSWORD>',
	database: process.env.DB_NAME || 'mod1_DB'
});

var connect_message = {
	"name" : "NodejsServer",
	"message" : "Success Connection"
};

// Catch data from Database and output console
connection.query('select * from messages', function(err, results, fields){
	console.log('---results---');
	console.log(results);
	console.log('---result end---');
	console.log('---fields---');
	console.log(fields);
	console.log('---fields end---');
});

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.set('port', process.env.PORT || 3000);

// uncomment after placing your favicon in /public
app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.use('/', routes);
app.use('/users', users);

// catch 404 and forward to error handler
app.use(function(req, res, next) {
    var err = new Error('Not Found');
    err.status = 404;
    next(err);
});

//--- Error Handlers ---//

// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
    app.use(function(err, req, res, next) {
        res.status(err.status || 500);
        res.render('error', {
            message: err.message,
            error: err
        });
    });
}

// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
    res.status(err.status || 500);
    res.render('error', {
        message: err.message,
        error: {}
    });
});

//--- End Error Handlers ---//

// Note : server listen this command : npm start
// listen server
//server.listen(3000);
//console.log('server is listening on port 3000');

//--- Socket.IO ---//

{'fraction_non_alphanumeric': 0.19587418300653595, 'fraction_numerical': 0.00980392156862745, 'mean_word_length': 3.6727099236641223, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '3027847', 'n_tokens_mistral': 1565, 'n_tokens_neox': 1519, 'n_words': 386}