Skip to content

Commit

Permalink
Update base ProtoSSChe server
Browse files Browse the repository at this point in the history
+https support and external config
  • Loading branch information
ivoyankulovski committed Sep 19, 2019
1 parent 59e099f commit 380a095
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 13 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -15,3 +15,7 @@ Folder `modules` contains examples and base extends of the server, including sam
Server executes requests non-stop and labels them by unique id **__reqid**, subclass server must extend functionality and create workers using [SkytoSS](https://github.com/ZetaRet/protoss/wiki/SkytoSS-Documentation).

[Preview server](https://protoss.zetaret.com/node/) in the browser using PING-shPONGle request returning omitted client data.

## [Wiki Pages](https://github.com/ZetaRet/protoss-nodejs-basic/wiki)
- [Change log](https://github.com/ZetaRet/protoss-nodejs-basic/wiki/Change-log)
- [HowTo](https://github.com/ZetaRet/protoss-nodejs-basic/wiki/HowTo)
36 changes: 29 additions & 7 deletions index.js
Expand Up @@ -5,6 +5,7 @@
**/

var http = require('http'),
https = require('https'),
fs = require('fs');

var env = {},
Expand Down Expand Up @@ -244,7 +245,7 @@ class ProtoSSChe {
return o;
}
}
var serverche;
var serverche, sk;
if (useXServer) {
var xpro = require(xserverModule),
xprocls = xpro.getExtendedServerProtoSS(ProtoSSChe);
Expand All @@ -253,15 +254,36 @@ if (useXServer) {
serverche = new ProtoSSChe();
}
serverche.env = env;
serverche.htserv = http.createServer(function(req, res) {
try {
serverche.onRequest(req, res);
} catch (e) {}
});
if (env.statsout && env.statsout.https === true) {
let httpsop = {};
if (!env.statsout.httpsop) {
httpsop.keyPath = 'key.pem';
httpsop.certPath = 'cert.pem';
} else {
for (sk in env.statsout.httpsop) httsop[sk] = env.statsout.httpsop[sk];
}
if (httpsop.keyPath) httpsop.key = fs.readFileSync(httpsop.keyPath);
if (httpsop.certPath) httpsop.cert = fs.readFileSync(httpsop.certPath);
if (httpsop.pfxPath) httpsop.pfx = fs.readFileSync(httpsop.pfxPath);
if (httpsop.caPath) httpsop.ca = [fs.readFileSync(httpsop.caPath)];
serverche.htserv = https.createServer(httpsop, function(req, res) {
try {
serverche.onRequest(req, res);
} catch (e) {}
});
} else {
serverche.htserv = http.createServer(function(req, res) {
try {
serverche.onRequest(req, res);
} catch (e) {}
});
}
if (!serverche.htserv.request) serverche.htserv.request = http.request;
if (!serverche.htserv.srequest) serverche.htserv.srequest = https.request;
if (htport >= 0) serverche.htserv.listen(htport);

module.exports.serverclass = ProtoSSChe;
module.exports.serverche = serverche;
module.exports.setEnv = setEnv;
module.exports.resetFSInterval = resetFSInterval;
module.exports.stopFSInterval = stopFSInterval;
module.exports.stopFSInterval = stopFSInterval;
8 changes: 5 additions & 3 deletions index.json
Expand Up @@ -2,8 +2,8 @@
"author": "Zeta Ret",
"description": "Basic ProtoSS Node.js Server",
"text": "Simple printed server from ProtoSS Packages using XeltoSS synthesis",
"requires": "http, fs",
"version": "1.1.3",
"requires": "http, https, fs",
"version": "1.2.3",
"date": "2019 - Today",
"supername": "zetaret.node::ProtoSSChe",
"inherits": null,
Expand Down Expand Up @@ -65,7 +65,9 @@
}
},
"static_examples": {
"stats": ["{reqnum:3, xserver:true, xserverModule: \"./modules/MyServer.js\", cookieid: \"mycookie\", htport: 3000}"]
"stats": [
"{reqnum:3, xserver:true, xserverModule: \"./modules/MyServer.js\", cookieid: \"mycookie\", htport: 3000, https: true, httpsop: {keyPath, certPath, pfxPath, caPath, ...anyOtherHTTPSOptionsParameter}"
]
},
"examples": {}
}
6 changes: 3 additions & 3 deletions index.md
@@ -1,8 +1,8 @@
> __Author: Zeta Ret__
> __Basic ProtoSS Node.js Server__
# Simple printed server from ProtoSS Packages using XeltoSS synthesis
> *Requires: http, fs*
> *Version: 1.1.3*
> *Requires: http, https, fs*
> *Version: 1.2.3*
> *Date: 2019 - Today*
__required*__
Expand Down Expand Up @@ -140,7 +140,7 @@ default './modules/XProtoSSChe.js',
__stats__ Object
default init, JSON Object loaded and updated frequently.
```
{reqnum:3, xserver:true, xserverModule: "./modules/MyServer.js", cookieid: "mycookie", htport: 3000}
{reqnum:3, xserver:true, xserverModule: "./modules/MyServer.js", cookieid: "mycookie", htport: 3000, https: true, httpsop: {keyPath, certPath, pfxPath, caPath, ...anyOtherHTTPSOptionsParameter}
```
##
### *Static Methods*
Expand Down

0 comments on commit 380a095

Please sign in to comment.