From a8249d91762e0017a9141179a07a0162cce01f0a Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Tue, 12 Sep 2023 21:20:23 +0200 Subject: [PATCH] Update to SVR.JS 3.4.36 --- hviews.txt | 1 - index.html | 11 +++++----- licenses/index.html | 8 +++---- svr.js | 51 ++++++++++++++++----------------------------- tests.html | 4 ++-- views.txt | 1 - 6 files changed, 29 insertions(+), 47 deletions(-) delete mode 100644 hviews.txt delete mode 100644 views.txt diff --git a/hviews.txt b/hviews.txt deleted file mode 100644 index 573541a..0000000 --- a/hviews.txt +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/index.html b/index.html index 9ffa673..387a800 100644 --- a/index.html +++ b/index.html @@ -1,7 +1,7 @@ - SVR.JS 3.4.35 + SVR.JS 3.4.36 -

Welcome to SVR.JS 3.4.35

+

Welcome to SVR.JS 3.4.36



@@ -38,7 +38,7 @@   "stackHidden": false,
  "enableRemoteLogBrowsing": false,
  "exposeServerVersion": true,
-   "disableServerSideScriptExpose": false,
+   "disableServerSideScriptExpose": true,
  "rewriteMap": [
    {
      "definingRegex": "/^\\/serverSideScript\\.js(?:$|[#?])/",
@@ -119,9 +119,8 @@

Changes:


Tests
diff --git a/licenses/index.html b/licenses/index.html index f8d92e3..951e3a1 100644 --- a/licenses/index.html +++ b/licenses/index.html @@ -1,7 +1,7 @@ - SVR.JS 3.4.35 Licenses + SVR.JS 3.4.36 Licenses -

SVR.JS 3.4.35 Licenses

-

SVR.JS 3.4.35

+

SVR.JS 3.4.36 Licenses

+

SVR.JS 3.4.36

MIT License

@@ -37,7 +37,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-

Packages used by SVR.JS 3.4.35 and utilities

+

Packages used by SVR.JS 3.4.36 and utilities

License: MIT
diff --git a/svr.js b/svr.js index 885970f..c02951e 100644 --- a/svr.js +++ b/svr.js @@ -71,7 +71,7 @@ function deleteFolderRecursive(path) { } var os = require("os"); -var version = "3.4.35"; +var version = "3.4.36"; var singlethreaded = false; if (process.versions) process.versions.svrjs = version; //Inject SVR.JS into process.versions @@ -3365,15 +3365,7 @@ if (!cluster.isPrimary) { return; } - if (version.indexOf("Nightly-") === 0 && (href == "/invoke500.svr" || (os.platform() == "win32" && href.toLowerCase() == "/invoke500.svr"))) { - if (uobject.query.crash !== undefined) throw new Error("Intentionally crashed"); - try { - throw new Error("This page is intended to return 500 code."); - } catch (ex) { - callServerError(500, undefined, generateErrorStack(ex)); - return; - } - } else if (allowStatus && (href == "/svrjsstatus.svr" || (os.platform() == "win32" && href.toLowerCase() == "/svrjsstatus.svr"))) { + if (allowStatus && (href == "/svrjsstatus.svr" || (os.platform() == "win32" && href.toLowerCase() == "/svrjsstatus.svr"))) { function formatRelativeTime(relativeTime) { var days = Math.floor(relativeTime / 60 / (60 * 24)); var dateDiff = new Date(relativeTime * 1000); @@ -3384,8 +3376,6 @@ if (!cluster.isPrimary) { res.writeHead(200, "OK", hdhds); res.end((head == "" ? "SVR.JS status" + (request.headers.host == undefined ? "" : " for " + String(req.headers.host).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")) + "" : head.replace(//i, "SVR.JS status" + (request.headers.host == undefined ? "" : " for " + String(req.headers.host).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")) + "")) + "

SVR.JS status" + (request.headers.host == undefined ? "" : " for " + String(req.headers.host).replace(/&/g, "&").replace(//g, ">")) + "

Server version: " + (exposeServerVersion ? "SVR.JS/" + version + " (" + getOS() + "; " + (process.isBun ? ("Bun/v" + process.versions.bun + "; like Node.JS/" + process.version) : ("Node.JS/" + process.version)) + ")" : "SVR.JS") + "

Current time: " + new Date().toString() + "
Thread start time: " + new Date(new Date() - (process.uptime() * 1000)).toString() + "
Thread uptime: " + formatRelativeTime(Math.floor(process.uptime())) + "
OS uptime: " + formatRelativeTime(os.uptime()) + "
Total request count: " + reqcounter + "
Average request rate: " + (Math.round((reqcounter / process.uptime()) * 100) / 100) + " requests/s" + (process.memoryUsage ? ("
Memory usage of thread: " + sizify(process.memoryUsage().rss) + "B") : "") + (process.cpuUsage ? ("
Total CPU usage by thread: u" + (process.cpuUsage().user / 1000) + "ms s" + (process.cpuUsage().system / 1000) + "ms - " + (Math.round((((process.cpuUsage().user + process.cpuUsage().system) / 1000000) / process.uptime()) * 1000) / 1000) + "%") : "") + "
Thread PID: " + process.pid + "
" + (foot == "" ? "" : foot)); return; - } else if (version.indexOf("Nightly-") === 0 && (href == "/crash.svr" || (os.platform() == "win32" && href.toLowerCase() == "/crash.svr"))) { - throw new Error("Intentionally crashed"); } ///////////////////////////////////////////// @@ -3416,38 +3406,35 @@ if (!cluster.isPrimary) { } return; } + //Check if index file exists if (req.url == "/" || stats.isDirectory()) { - fs.stat("./" + pth + "/.notindex".replace(/\/+/g, "/"), function (e) { - if (e) { - fs.stat(("./" + pth + "/index.html").replace(/\/+/g, "/"), function (e, s) { + fs.stat(("./" + pth + "/index.html").replace(/\/+/g, "/"), function (e, s) { + if (e || !s.isFile()) { + fs.stat(("./" + pth + "/index.htm").replace(/\/+/g, "/"), function (e, s) { if (e || !s.isFile()) { - fs.stat(("./" + pth + "/index.htm").replace(/\/+/g, "/"), function (e, s) { + fs.stat(("./" + pth + "/index.xhtml").replace(/\/+/g, "/"), function (e, s) { if (e || !s.isFile()) { - fs.stat(("./" + pth + "/index.xhtml").replace(/\/+/g, "/"), function (e, s) { - if (e || !s.isFile()) { - properServe() - } else { - stats = s; - pth = (pth + "/index.xhtml").replace(/\/+/g, "/"); - ext = "xhtml"; - properServe(); - } - }); + properServe() } else { stats = s; - pth = (pth + "/index.htm").replace(/\/+/g, "/"); - ext = "htm"; + pth = (pth + "/index.xhtml").replace(/\/+/g, "/"); + ext = "xhtml"; properServe(); } }); } else { stats = s; - pth = (pth + "/index.html").replace(/\/+/g, "/"); - ext = "html"; + pth = (pth + "/index.htm").replace(/\/+/g, "/"); + ext = "htm"; properServe(); } }); + } else { + stats = s; + pth = (pth + "/index.html").replace(/\/+/g, "/"); + ext = "html"; + properServe(); } }); } else { @@ -4197,9 +4184,7 @@ if (!cluster.isPrimary) { } } } catch (ex) { - //CRASH HANDLER - if (ex.message == "Intentionally crashed") throw ex; //If intentionally crashed, then crash SVR.JS - callServerError(500, undefined, generateErrorStack(ex)); //Else just return 500 error + callServerError(500, undefined, generateErrorStack(ex)); //Return 500 error } } diff --git a/tests.html b/tests.html index 850863d..f669f86 100644 --- a/tests.html +++ b/tests.html @@ -1,7 +1,7 @@ - SVR.JS 3.4.35 Tests + SVR.JS 3.4.36 Tests -

SVR.JS 3.4.35 Tests

+

SVR.JS 3.4.36 Tests

Directory

Directory (with query)

diff --git a/views.txt b/views.txt deleted file mode 100644 index 573541a..0000000 --- a/views.txt +++ /dev/null @@ -1 +0,0 @@ -0