-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
50 lines (41 loc) · 1.33 KB
/
index.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
38
39
40
41
42
43
44
45
46
47
48
49
50
'use strict';
process.title = 'node-emoporemilio';
//* DEPENDENCIES *//
import environment from './environment.js';
import express from 'express';
import fs from 'fs';
import http from 'http';
import https from 'https';
import { Server } from 'socket.io';
import { setupBot } from './bot.js';
//* EXPRESS INIT *//
var app = express();
let server = null;
if (process.env.NODE_ENV === 'production') {
console.log(environment.APP_BASE_PATH);
app.use(express.static(environment.APP_BASE_PATH + 'public'));
//* HTTPS *//
const privateKey = fs.readFileSync(environment.privateKey);
const certificate = fs.readFileSync(environment.certificate);
const chain = fs.readFileSync(environment.chain);
const options = { key: privateKey, cert: certificate, ca: chain };
server = https
.createServer(options, app)
.listen(environment.EXPRESS_HTTPS_PORT, function () {
console.log(
'EmoPorEmilio corriendo en el puerto ' + environment.EXPRESS_HTTPS_PORT
);
});
} else {
app.use(express.static(environment.APP_BASE_PATH_LOCAL + 'public'));
server = http
.createServer(app)
.listen(environment.EXPRESS_HTTPS_PORT, function () {
console.log(
'EmoPorEmilio corriendo en el puerto ' + environment.EXPRESS_HTTPS_PORT
);
});
}
//* BOT *//
//const io = new Server(server);
//setupBot(io);