daveappserver 0.7.3 → 0.7.5
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/appserver.js +58 -51
- package/package.json +1 -1
package/appserver.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var myVersion = "0.7.
|
|
1
|
+
var myVersion = "0.7.5", myProductName = "daveAppServer";
|
|
2
2
|
|
|
3
3
|
exports.start = startup;
|
|
4
4
|
exports.notifySocketSubscribers = notifySocketSubscribers;
|
|
@@ -1411,69 +1411,76 @@ function startup (options, callback) {
|
|
|
1411
1411
|
});
|
|
1412
1412
|
}
|
|
1413
1413
|
function returnServerHomePage () {
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
if (theRequest.addToPagetable !== undefined) { //3/9/21 by DW
|
|
1439
|
-
for (var x in theRequest.addToPagetable) {
|
|
1440
|
-
pagetable [x] = theRequest.addToPagetable [x];
|
|
1441
|
-
}
|
|
1442
|
-
}
|
|
1443
|
-
if (config.addMacroToPagetable !== undefined) {
|
|
1444
|
-
config.addMacroToPagetable (pagetable, theRequest); //8/10/22 by DW
|
|
1445
|
-
}
|
|
1446
|
-
|
|
1447
|
-
function replaceAllAndReturnHtml () {
|
|
1448
|
-
var pagetext = utils.multipleReplaceAll (templatetext.toString (), pagetable, false, "[%", "%]");
|
|
1449
|
-
returnHtml (pagetext);
|
|
1450
|
-
}
|
|
1451
|
-
if (config.asyncAddMacroToPagetable !== undefined) { //8/10/22 by DW
|
|
1452
|
-
config.asyncAddMacroToPagetable (pagetable, theRequest, function () {
|
|
1453
|
-
replaceAllAndReturnHtml ();
|
|
1414
|
+
var pagetable = {
|
|
1415
|
+
productName: config.productName,
|
|
1416
|
+
productNameForDisplay: config.productNameForDisplay,
|
|
1417
|
+
version: config.version,
|
|
1418
|
+
urlServerForClient: config.urlServerForClient,
|
|
1419
|
+
urlWebsocketServerForClient: config.urlWebsocketServerForClient,
|
|
1420
|
+
flEnableLogin: config.flEnableLogin,
|
|
1421
|
+
prefsPath: config.prefsPath,
|
|
1422
|
+
docsPath: config.docsPath,
|
|
1423
|
+
flUseTwitterIdentity: config.flUseTwitterIdentity, //2/6/23 by DW
|
|
1424
|
+
idGitHubClient: config.githubClientId, //11/9/21 by DW
|
|
1425
|
+
flWebsocketEnabled: config.flWebsocketEnabled, //2/8/23 by DW
|
|
1426
|
+
urlServerHomePageSource: config.urlServerHomePageSource, //9/16/23 by DW
|
|
1427
|
+
pathServerHomePageSource: config.pathServerHomePageSource //9/16/23 by DW
|
|
1428
|
+
};
|
|
1429
|
+
function getTemplateText (callback) {
|
|
1430
|
+
if (pagetable.pathServerHomePageSource !== undefined) {
|
|
1431
|
+
fs.readFile (pagetable.pathServerHomePageSource, function (err, templatetext) {
|
|
1432
|
+
if (err) {
|
|
1433
|
+
callback (err);
|
|
1434
|
+
}
|
|
1435
|
+
else {
|
|
1436
|
+
callback (undefined, templatetext);
|
|
1437
|
+
}
|
|
1454
1438
|
});
|
|
1455
1439
|
}
|
|
1456
1440
|
else {
|
|
1457
|
-
|
|
1441
|
+
request (pagetable.urlServerHomePageSource, function (err, response, templatetext) {
|
|
1442
|
+
if (err) {
|
|
1443
|
+
callback (err);
|
|
1444
|
+
}
|
|
1445
|
+
else {
|
|
1446
|
+
if ((response.statusCode >= 200) && (response.statusCode <= 299)) {
|
|
1447
|
+
callback (undefined, templatetext);
|
|
1448
|
+
}
|
|
1449
|
+
else {
|
|
1450
|
+
const message = "HTTP error == " + response.statusCode;
|
|
1451
|
+
callback ({message});
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
});
|
|
1458
1455
|
}
|
|
1459
1456
|
}
|
|
1460
|
-
|
|
1461
|
-
|
|
1457
|
+
function buildAndServeHomepage () {
|
|
1458
|
+
getTemplateText (function (err, templatetext) {
|
|
1462
1459
|
if (err) {
|
|
1463
|
-
|
|
1460
|
+
returnError (err);
|
|
1464
1461
|
}
|
|
1465
1462
|
else {
|
|
1466
|
-
|
|
1463
|
+
const pagetext = utils.multipleReplaceAll (templatetext.toString (), pagetable, false, "[%", "%]");
|
|
1464
|
+
returnHtml (pagetext);
|
|
1467
1465
|
}
|
|
1468
1466
|
});
|
|
1469
1467
|
}
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1468
|
+
if (theRequest.addToPagetable !== undefined) { //3/9/21 by DW
|
|
1469
|
+
for (var x in theRequest.addToPagetable) {
|
|
1470
|
+
pagetable [x] = theRequest.addToPagetable [x];
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
if (config.addMacroToPagetable !== undefined) {
|
|
1474
|
+
config.addMacroToPagetable (pagetable, theRequest); //8/10/22 by DW
|
|
1475
|
+
}
|
|
1476
|
+
if (config.asyncAddMacroToPagetable !== undefined) { //8/10/22 by DW
|
|
1477
|
+
config.asyncAddMacroToPagetable (pagetable, theRequest, function () {
|
|
1478
|
+
buildAndServeHomepage ();
|
|
1475
1479
|
});
|
|
1476
1480
|
}
|
|
1481
|
+
else {
|
|
1482
|
+
buildAndServeHomepage ();
|
|
1483
|
+
}
|
|
1477
1484
|
}
|
|
1478
1485
|
function callWithScreenname (callback) {
|
|
1479
1486
|
if (config.flUseTwitterIdentity) { //2/6/23 by DW
|