@blaasvaer/frmwrk 0.3.6 → 0.3.8

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.
Files changed (2) hide show
  1. package/index.js +26 -3
  2. 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,28 @@ console.log("Authorize - check credentials:", credentials);
130
134
  * Create and start the server
131
135
  * @return {function} Server instance
132
136
  */
133
- const server = http.createServer( handleRequest ).listen(port, hostname, () => {
134
- console.log(`Server running at http://${hostname}:${port}`);
135
- });
137
+ if ( config.protocol === 'https' ) {
138
+ /**
139
+ * SSL Configurations options
140
+ * These paths should be provided in your framework's config object
141
+ */
142
+ const sslOptions = {
143
+ key: fs.readFileSync(config.sslKeyPath || './certs/key.pem'),
144
+ cert: fs.readFileSync(config.sslCertPath || './certs/cert.pem')
145
+ };
146
+
147
+ /**
148
+ * Create and start the secure server
149
+ * @return {function} Server instance
150
+ */
151
+ server = https.createServer( sslOptions, handleRequest ).listen(port, hostname, () => {
152
+ console.log(`Server running at https://${hostname}:${port}`);
153
+ });
154
+ } else {
155
+ server = http.createServer( handleRequest ).listen(port, hostname, () => {
156
+ console.log(`Server running at http://${hostname}:${port}`);
157
+ });
158
+ }
136
159
 
137
160
  if ( config.enable_socket_io ) {
138
161
  _io = new Server( server );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blaasvaer/frmwrk",
3
- "version": "0.3.6",
3
+ "version": "0.3.8",
4
4
  "description": "My personal Node framework",
5
5
  "main": "index.js",
6
6
  "scripts": {