@blaasvaer/frmwrk 0.3.6 → 0.3.9
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/index.js +31 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
/**
|
|
10
10
|
* Native modules
|
|
11
11
|
*/
|
|
12
|
+
const fs = require('fs');
|
|
12
13
|
const http = require('http');
|
|
14
|
+
const https = require('https');
|
|
13
15
|
const { Server } = require('socket.io');
|
|
14
16
|
|
|
15
17
|
let port;
|
|
@@ -122,6 +124,8 @@ console.log("Authorize - check credentials:", credentials);
|
|
|
122
124
|
*/
|
|
123
125
|
Install( config )
|
|
124
126
|
.then(( result ) => {
|
|
127
|
+
let server;
|
|
128
|
+
|
|
125
129
|
/**
|
|
126
130
|
* Run optional post install processes here …
|
|
127
131
|
*/
|
|
@@ -130,9 +134,33 @@ console.log("Authorize - check credentials:", credentials);
|
|
|
130
134
|
* Create and start the server
|
|
131
135
|
* @return {function} Server instance
|
|
132
136
|
*/
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
137
|
+
if ( config.protocol === 'https' ) {
|
|
138
|
+
/**
|
|
139
|
+
* Set port
|
|
140
|
+
*/
|
|
141
|
+
port = 443;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* SSL Configurations options
|
|
145
|
+
* These paths should be provided in your framework's config object
|
|
146
|
+
*/
|
|
147
|
+
const sslOptions = {
|
|
148
|
+
key: fs.readFileSync(config.sslKeyPath || './certs/key.pem'),
|
|
149
|
+
cert: fs.readFileSync(config.sslCertPath || './certs/cert.pem')
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Create and start the secure server
|
|
154
|
+
* @return {function} Server instance
|
|
155
|
+
*/
|
|
156
|
+
server = https.createServer( sslOptions, handleRequest ).listen(port, hostname, () => {
|
|
157
|
+
console.log(`Server running at https://${hostname}:${port}`);
|
|
158
|
+
});
|
|
159
|
+
} else {
|
|
160
|
+
server = http.createServer( handleRequest ).listen(port, hostname, () => {
|
|
161
|
+
console.log(`Server running at http://${hostname}:${port}`);
|
|
162
|
+
});
|
|
163
|
+
}
|
|
136
164
|
|
|
137
165
|
if ( config.enable_socket_io ) {
|
|
138
166
|
_io = new Server( server );
|