server.js
var app = require('express')();
var server = require('https').Server(app);
var io = require('socket.io')(server);
var mysql = require('mysql');
server.listen(3333);
if (fs.existsSync('ssl/cert.key') && fs.existsSync('ssl/cert.crt')) {
options = {
key: fs.readFileSync('ssl/cert.key'),
cert: fs.readFileSync('ssl/cert.crt')
};
server = require('https').Server(options, express);
} else {
server = require('http').Server(express);
}
io = require('socket.io').listen(server);