nails-boilerplate 0.12.0 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/nails.js
CHANGED
|
@@ -96,17 +96,32 @@ function startServer(config) {
|
|
|
96
96
|
express_app.use(application.router.express_router);
|
|
97
97
|
var ip = application.config.IP || 'localhost';
|
|
98
98
|
var port = application.config.PORT || 3000;
|
|
99
|
-
console.log("starting nails. listening to ", ip + ':' + port);
|
|
100
|
-
express_app.listen(port, ip, () => {
|
|
101
|
-
nails.events.emit("ready", null);
|
|
102
|
-
});
|
|
103
99
|
|
|
104
|
-
|
|
105
|
-
|
|
100
|
+
let startHttp = 'ENABLE_HTTP' in application.config && !!application.config.ENABLE_HTTP;
|
|
101
|
+
let startHttps = !!application.config.ENABLE_HTTPS;
|
|
102
|
+
|
|
103
|
+
if (!startHttp && !startHttps) {
|
|
104
|
+
console.error("Either ENABLE_HTTPS or ENABLE_HTTP must be set for nails to start");
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
let atLeastOneServerStarted = false;
|
|
108
|
+
let serverStartedCallback = () => {
|
|
109
|
+
if (atLeastOneServerStarted) return;
|
|
110
|
+
nails.events.emit("ready", null);
|
|
111
|
+
atLeastOneServerStarted = true;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (startHttp) {
|
|
115
|
+
console.log("starting nails HTTP server. listening to ", ip + ':' + port);
|
|
116
|
+
express_app.listen(port, ip, serverStartedCallback);
|
|
117
|
+
|
|
118
|
+
}
|
|
119
|
+
if (startHttps) {
|
|
120
|
+
console.log(`starting nails HTTPS server. Listening to ${ip}:${application.config.SSL_PORT}`);
|
|
106
121
|
https.createServer({
|
|
107
122
|
key: application.config.PRIVATE_KEY,
|
|
108
123
|
cert: application.config.CERTIFICATE
|
|
109
|
-
}, express_app).listen(application.config.SSL_PORT);
|
|
124
|
+
}, express_app).listen(application.config.SSL_PORT, serverStartedCallback);
|
|
110
125
|
}
|
|
111
126
|
});
|
|
112
127
|
}
|
package/package.json
CHANGED