-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
29 lines (25 loc) · 823 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
const server = require('./src/bin/main').server;
const fs = require('fs');
const serverOptions = require('./src/bin/main').serverOptions;
let privateKey, certificate, credentials, httpsServer, http, https, httpServer;
/**
* STARTUP SERVER
*/
if (serverOptions.http) {
http = require('http');
httpServer = http.createServer(server);
}
if (serverOptions.https) {
https = require('https');
privateKey = fs.readFileSync('certificates/key.pem', 'utf8');
certificate = fs.readFileSync('certificates/cert.pem', 'utf8');
credentials = {key: privateKey, cert: certificate};
httpsServer = https.createServer(credentials, server);
}
const startNext = require('./src/bin/next').startServer;
startNext(server, serverOptions, {
http: http,
httpServer: httpServer,
https: https,
httpsServer: httpsServer,
});