server-status-check
Version:
query the server periodically to check whether it is up
47 lines (46 loc) • 3.68 kB
JavaScript
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.hydrationOutputGen = exports.mockViewDataWithEmptyErros = exports.mockViewDataWithErros = void 0;
var siteTitle = "Hello";
var secondsBeforeAutoRefresh = "234";
var statusInfo = {
statusName: "my status",
friendlyFullSentence: "asdfasdf",
dateLastChecked: '08/10/1987',
checkIntervalInMinutes: '1',
checksSpreeCount: "899",
aliveForYMDHMS: "1234",
errors: [
{ message: 'error 0' },
{ message: 'error 1' }
]
};
exports.mockViewDataWithErros = {
siteTitle: siteTitle,
secondsBeforeAutoRefresh: secondsBeforeAutoRefresh,
statusInfo: statusInfo,
};
exports.mockViewDataWithEmptyErros = {
siteTitle: siteTitle,
secondsBeforeAutoRefresh: secondsBeforeAutoRefresh,
statusInfo: __assign(__assign({}, statusInfo), { errors: [] }),
};
var hydrationOutputGen = function (data) {
var siteTitle = data.siteTitle, secondsBeforeAutoRefresh = data.secondsBeforeAutoRefresh, statusInfo = data.statusInfo;
var errorsHydrated = statusInfo.errors.length > 0
? "\n <tr>\n <td>Error message :</td>\n <td>" + statusInfo.errors[0].message + "</td>\n </tr>\n <tr>\n <td>Error message :</td>\n <td>" + statusInfo.errors[1].message + "</td>\n </tr>\n"
: '';
return "<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\">\n <title>" + siteTitle + "</title>\n <meta name=\"description\" content=\"Server status check\">\n <meta name=\"author\" content=\"Guillermo Pages\">\n <meta name=\"company\" content=\"Meow LLC\">\n <link rel=\"stylesheet\" href=\"css/styles.css?v=1.0\">\n <meta http-equiv=\"refresh\" content=\"" + secondsBeforeAutoRefresh + "\" >\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, minimum-scale=1\" />\n </head>\n\n <body>\n <div id=\"main-container\">\n <header>\n <h1>" + siteTitle + "</h1>\n </header>\n <div id=\"content\">\n <p class=\"status-" + statusInfo.statusName + "\"></p>\n <p>" + statusInfo.friendlyFullSentence + "</p>\n <table>\n <thead>\n <tr>\n <th colspan=\"2\">Stats</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>Current status</td>\n <td class=\"status-" + statusInfo.statusName + "\">" + statusInfo.statusName + "</td>\n </tr>\n <tr>\n <td>Last check date</td>\n <td>" + statusInfo.dateLastChecked + "</td>\n </tr>\n <tr>\n <td>Checking every</td>\n <td>" + statusInfo.checkIntervalInMinutes + " min.</td>\n </tr>\n <tr>\n <td>Times checked</td>\n <td>" + statusInfo.checksSpreeCount + "</td>\n </tr>\n <tr>\n <td>Bot alive for</td>\n <td>" + statusInfo.aliveForYMDHMS + "</td>\n </tr>\n " + errorsHydrated + "\n </tbody>\n </table>\n </div>\n </div>\n </body>\n</html>\n";
};
exports.hydrationOutputGen = hydrationOutputGen;