daveappserver 0.7.5 → 0.7.6
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 +78 -59
- package/package.json +1 -1
package/appserver.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var myVersion = "0.7.
|
|
1
|
+
var myVersion = "0.7.6", myProductName = "daveAppServer";
|
|
2
2
|
|
|
3
3
|
exports.start = startup;
|
|
4
4
|
exports.notifySocketSubscribers = notifySocketSubscribers;
|
|
@@ -478,44 +478,49 @@ function cleanFileStats (stats) { //4/19/21 by DW
|
|
|
478
478
|
});
|
|
479
479
|
}
|
|
480
480
|
function publishFile (screenname, relpath, type, flprivate, filetext, callback) {
|
|
481
|
-
if (config.
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
config.publishFile (f, screenname, relpath, type, flprivate, filetext, url);
|
|
481
|
+
if (config.publishStaticFile !== undefined) { //9/20/23 by DW
|
|
482
|
+
config.publishStaticFile (screenname, relpath, type, flprivate, filetext, callback);
|
|
483
|
+
}
|
|
484
|
+
else {
|
|
485
|
+
if (config.flStorageEnabled) {
|
|
486
|
+
if (config.flUseS3ForStorage) {
|
|
487
|
+
saveFileToS3 (screenname, relpath, type, flprivate, filetext, callback);
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
var f = getFilePath (screenname, relpath, flprivate);
|
|
491
|
+
utils.sureFilePath (f, function () {
|
|
492
|
+
var now = new Date ();
|
|
493
|
+
fs.writeFile (f, filetext, function (err) {
|
|
494
|
+
if (err) {
|
|
495
|
+
callback (err);
|
|
497
496
|
}
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
497
|
+
else {
|
|
498
|
+
var url = (flprivate) ? undefined : config.urlServerForClient + screenname + "/" + relpath;
|
|
499
|
+
if (config.publishFile !== undefined) { //3/18/22 by DW
|
|
500
|
+
config.publishFile (f, screenname, relpath, type, flprivate, filetext, url);
|
|
501
|
+
}
|
|
502
|
+
if (!flprivate) {
|
|
503
|
+
notifySocketSubscribers ("update", filetext, true, function (conn) { //3/6/2 by DW -- payload is a string
|
|
504
|
+
if (conn.appData.urlToWatch == url) {
|
|
505
|
+
return (true);
|
|
506
|
+
}
|
|
507
|
+
else {
|
|
508
|
+
return (false);
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
callback (undefined, {
|
|
513
|
+
url,
|
|
514
|
+
whenLastUpdate: now
|
|
506
515
|
});
|
|
507
516
|
}
|
|
508
|
-
|
|
509
|
-
url,
|
|
510
|
-
whenLastUpdate: now
|
|
511
|
-
});
|
|
512
|
-
}
|
|
517
|
+
});
|
|
513
518
|
});
|
|
514
|
-
}
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
else {
|
|
522
|
+
callback ({message: "Can't publish the file because the feature is not enabled on the server."});
|
|
515
523
|
}
|
|
516
|
-
}
|
|
517
|
-
else {
|
|
518
|
-
callback ({message: "Can't publish the file because the feature is not enabled on the server."});
|
|
519
524
|
}
|
|
520
525
|
}
|
|
521
526
|
function getFile (screenname, relpath, flprivate, callback) {
|
|
@@ -526,35 +531,50 @@ function cleanFileStats (stats) { //4/19/21 by DW
|
|
|
526
531
|
}
|
|
527
532
|
callback (err);
|
|
528
533
|
}
|
|
529
|
-
|
|
530
|
-
if (config.
|
|
531
|
-
|
|
534
|
+
function getFromStaticFIlesystem () {
|
|
535
|
+
if (config.flStorageEnabled) {
|
|
536
|
+
if (config.flUseS3ForStorage) {
|
|
537
|
+
getFileFromS3 (screenname, relpath, flprivate, callback);
|
|
538
|
+
}
|
|
539
|
+
else {
|
|
540
|
+
var f = getFilePath (screenname, relpath, flprivate);
|
|
541
|
+
fs.readFile (f, function (err, filetext) {
|
|
542
|
+
if (err) {
|
|
543
|
+
errcallback (err);
|
|
544
|
+
}
|
|
545
|
+
else {
|
|
546
|
+
fs.stat (f, function (err, stats) {
|
|
547
|
+
if (err) {
|
|
548
|
+
errcallback (err);
|
|
549
|
+
}
|
|
550
|
+
else {
|
|
551
|
+
var data = {
|
|
552
|
+
filedata: filetext.toString (),
|
|
553
|
+
filestats: cleanFileStats (stats)
|
|
554
|
+
};
|
|
555
|
+
callback (undefined, data);
|
|
556
|
+
}
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
}
|
|
532
561
|
}
|
|
533
562
|
else {
|
|
534
|
-
|
|
535
|
-
fs.readFile (f, function (err, filetext) {
|
|
536
|
-
if (err) {
|
|
537
|
-
errcallback (err);
|
|
538
|
-
}
|
|
539
|
-
else {
|
|
540
|
-
fs.stat (f, function (err, stats) {
|
|
541
|
-
if (err) {
|
|
542
|
-
errcallback (err);
|
|
543
|
-
}
|
|
544
|
-
else {
|
|
545
|
-
var data = {
|
|
546
|
-
filedata: filetext.toString (),
|
|
547
|
-
filestats: cleanFileStats (stats)
|
|
548
|
-
};
|
|
549
|
-
callback (undefined, data);
|
|
550
|
-
}
|
|
551
|
-
});
|
|
552
|
-
}
|
|
553
|
-
});
|
|
563
|
+
callback ({message: "Can't get the file because the feature is not enabled on the server."});
|
|
554
564
|
}
|
|
555
565
|
}
|
|
566
|
+
if (config.getStaticFile !== undefined) { //9/20/23 by DW
|
|
567
|
+
config.getStaticFile (screenname, relpath, flprivate, function (err, data) {
|
|
568
|
+
if (err) {
|
|
569
|
+
getFromStaticFIlesystem ();
|
|
570
|
+
}
|
|
571
|
+
else {
|
|
572
|
+
callback (undefined, data);
|
|
573
|
+
}
|
|
574
|
+
});
|
|
575
|
+
}
|
|
556
576
|
else {
|
|
557
|
-
|
|
577
|
+
getFromStaticFIlesystem ();
|
|
558
578
|
}
|
|
559
579
|
}
|
|
560
580
|
function getFileList (screenname, flprivate, callback) {
|
|
@@ -1791,7 +1811,6 @@ function startup (options, callback) {
|
|
|
1791
1811
|
}
|
|
1792
1812
|
}
|
|
1793
1813
|
|
|
1794
|
-
|
|
1795
1814
|
utils.copyScalars (options, config); //1/22/21 by DW
|
|
1796
1815
|
readConfigJson (function () { //readConfig (fnameConfig, config, true, function () { //anything can be overridden by config.json
|
|
1797
1816
|
readConfig (fnameStats, stats, false, function () {
|