-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
executable file
·37 lines (29 loc) · 938 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var express = require("express");
var app = express();
var http = require("http").createServer(app);
var https = require('https');
var fs = require('fs');
var privateKey = fs.readFileSync('file.pem', 'utf8');
var certificate = fs.readFileSync('file.crt', 'utf8');
var credentials = {key: privateKey, cert: certificate};
var httpsServer = https.createServer(credentials, app);
var io = require("socket.io").listen(httpsServer);
// var readDir = require('readdir');
var main = require('./main');
var config = require('./config');
var router = require('./router');
var m = new main(app, io);
/*
* Server config
*/
config(app, express);
/**
* Server routing and io events
*/
router(app, io, m);
/**
* Start the http server at port and IP defined before
*/
httpsServer.listen(app.get("port"), /*app.get("ipaddr"),*/ function() {
console.log("Server up and running. Go to https://localhost:" + app.get("port"));
});