-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
33 lines (27 loc) · 947 Bytes
/
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
require('dotenv').config();
const { NODE_ENV } = process.env;
var fs = require('fs'),
http = require('http'),
https = require('https'),
express = require('express'),
session = require('express-session'),
passportRoutes = require('./passport'),
regularRoutes = require('./routes'),
app = express();
app.use(session({
secret: process.env.SESSION_SECRET,
resave: false,
saveUninitialized: false,
cookie: { secure: NODE_ENV == 'production' ? true : false }
}));
app.use(passportRoutes);
app.use(regularRoutes);
http.createServer(app).listen(NODE_ENV == 'production' ? 80 : 5000);
if (NODE_ENV == 'production') {
const credentials = {
key: fs.readFileSync('/etc/letsencrypt/live/maherbrini.tk/privkey.pem', 'utf8'),
cert: fs.readFileSync('/etc/letsencrypt/live/maherbrini.tk/cert.pem', 'utf8'),
ca: fs.readFileSync('/etc/letsencrypt/live/maherbrini.tk/chain.pem', 'utf8')
};
https.createServer(credentials, app).listen(443);
}