mirror of
https://github.com/rajnandan1/kener.git
synced 2026-03-13 14:29:57 -05:00
dotenv
This commit is contained in:
13
package-lock.json
generated
13
package-lock.json
generated
@@ -14,6 +14,7 @@
|
||||
"bits-ui": "^0.9.9",
|
||||
"clsx": "^2.0.0",
|
||||
"croner": "^7.0.5",
|
||||
"dotenv": "^16.4.5",
|
||||
"express": "^4.18.2",
|
||||
"fs-extra": "^11.1.1",
|
||||
"js-yaml": "^4.1.0",
|
||||
@@ -1627,6 +1628,18 @@
|
||||
"resolved": "https://registry.npmjs.org/dlv/-/dlv-1.1.3.tgz",
|
||||
"integrity": "sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA=="
|
||||
},
|
||||
"node_modules/dotenv": {
|
||||
"version": "16.4.5",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz",
|
||||
"integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==",
|
||||
"license": "BSD-2-Clause",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://dotenvx.com"
|
||||
}
|
||||
},
|
||||
"node_modules/ee-first": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
"scripts": {
|
||||
"build": "node scripts/check.js && vite build",
|
||||
"serve": "node prod.js",
|
||||
"kener:dev": "cross-env NODE_ENV=development PUBLIC_KENER_FOLDER=./static/kener node scripts/check.js && concurrently \"cross-env NODE_ENV=development PUBLIC_KENER_FOLDER=./static/kener node dev.js\" \"cross-env NODE_ENV=development PUBLIC_KENER_FOLDER=./static/kener vite dev\"",
|
||||
"kener:dev-monitor": "cross-env NODE_ENV=development PUBLIC_KENER_FOLDER=./static/kener node dev.js",
|
||||
"kener:dev": "cross-env node scripts/check.js && concurrently \"cross-env node dev.js\" \"cross-env vite dev\"",
|
||||
"kener:dev-monitor": "cross-env node dev.js",
|
||||
"kener:build": "cross-env NODE_ENV=production node scripts/check.js && cross-env NODE_ENV=production vite build",
|
||||
"kener": "cross-env NODE_ENV=production node prod.js",
|
||||
"prettify": "prettier --write ."
|
||||
@@ -61,6 +61,7 @@
|
||||
"bits-ui": "^0.9.9",
|
||||
"clsx": "^2.0.0",
|
||||
"croner": "^7.0.5",
|
||||
"dotenv": "^16.4.5",
|
||||
"express": "^4.18.2",
|
||||
"fs-extra": "^11.1.1",
|
||||
"js-yaml": "^4.1.0",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { FOLDER, FOLDER_MONITOR, FOLDER_SITE, ENV } from "./constants.js";
|
||||
import { IsStringURLSafe } from "./tool.js";
|
||||
|
||||
import dotenv from "dotenv";
|
||||
dotenv.config();
|
||||
import fs from "fs-extra";
|
||||
let STATUS_OK = false;
|
||||
if (!!process.env.PUBLIC_KENER_FOLDER) {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// Define your constants
|
||||
import dotenv from "dotenv";
|
||||
dotenv.config();
|
||||
const FOLDER = process.env.PUBLIC_KENER_FOLDER;
|
||||
const ENV = process.env.NODE_ENV;
|
||||
const MONITOR = "./config/monitors.yaml";
|
||||
|
||||
@@ -10,6 +10,8 @@ import {
|
||||
import { GetIncidents, GetEndTimeFromBody, GetStartTimeFromBody, CloseIssue } from "./github.js";
|
||||
import Randomstring from "randomstring";
|
||||
import Queue from "queue";
|
||||
import dotenv from "dotenv";
|
||||
dotenv.config();
|
||||
|
||||
const Kener_folder = process.env.PUBLIC_KENER_FOLDER;
|
||||
const apiQueue = new Queue({
|
||||
@@ -103,17 +105,15 @@ function replaceAllOccurrences(originalString, searchString, replacement) {
|
||||
return replacedString;
|
||||
}
|
||||
const pingCall = async (hostsV4, hostsV6) => {
|
||||
|
||||
let alive = true;
|
||||
let latencyTotal = 0;
|
||||
let countHosts = hostsV4.length + hostsV6.length;
|
||||
|
||||
|
||||
for (let i = 0; i < hostsV4.length; i++) {
|
||||
const host = hostsV4[i].trim();
|
||||
try {
|
||||
let res = await ping.promise.probe(host);
|
||||
alive = alive && res.alive;
|
||||
alive = alive && res.alive;
|
||||
latencyTotal += res.time;
|
||||
} catch (error) {
|
||||
alive = alive && false;
|
||||
@@ -140,7 +140,7 @@ const pingCall = async (hostsV4, hostsV6) => {
|
||||
latency: parseInt(latencyTotal / countHosts),
|
||||
type: "realtime"
|
||||
};
|
||||
}
|
||||
};
|
||||
const apiCall = async (envSecrets, url, method, headers, body, timeout, monitorEval) => {
|
||||
let axiosHeaders = {};
|
||||
axiosHeaders["User-Agent"] = "Kener/0.0.1";
|
||||
@@ -345,7 +345,7 @@ const Minuter = async (envSecrets, monitor, githubConfig) => {
|
||||
let pingResponse = await pingCall(monitor.ping.hostsV4, monitor.ping.hostsV6);
|
||||
pingData[startOfMinute] = pingResponse;
|
||||
}
|
||||
|
||||
|
||||
webhookData = await getWebhookData(monitor);
|
||||
manualData = await manualIncident(monitor, githubConfig);
|
||||
//merge noData, apiData, webhookData, dayData
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
import axios from "axios";
|
||||
import { GetMinuteStartNowTimestampUTC } from "./tool.js";
|
||||
import { marked } from "marked";
|
||||
import { fileURLToPath } from "url";
|
||||
import { dirname } from "path";
|
||||
import dotenv from "dotenv";
|
||||
dotenv.config();
|
||||
const GH_TOKEN = process.env.GH_TOKEN;
|
||||
const GhnotconfireguredMsg =
|
||||
"owner or repo or GH_TOKEN is undefined. Read the docs to configure github: https://kener.ing/docs#h2github-setup";
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
// create sitemap.xml
|
||||
import fs from "fs-extra";
|
||||
let siteMap = "";
|
||||
import dotenv from "dotenv";
|
||||
dotenv.config();
|
||||
const site = JSON.parse(fs.readFileSync(process.env.PUBLIC_KENER_FOLDER + "/site.json", "utf8"));
|
||||
const monitors = JSON.parse(
|
||||
fs.readFileSync(process.env.PUBLIC_KENER_FOLDER + "/monitors.json", "utf8")
|
||||
|
||||
@@ -5,6 +5,7 @@ if it does, it will read the file and parse it into a json array of objects
|
||||
each objects will have a name, url, method: required
|
||||
name of each of these objects need to be unique
|
||||
*/
|
||||
import * as dotenv from "dotenv";
|
||||
import fs from "fs-extra";
|
||||
import yaml from "js-yaml";
|
||||
import { Cron } from "croner";
|
||||
@@ -105,7 +106,7 @@ const Startup = async () => {
|
||||
) {
|
||||
monitors[i].includeDegradedInDowntime = false;
|
||||
}
|
||||
if(hasPing) {
|
||||
if (hasPing) {
|
||||
let hostsV4 = monitor.ping.hostsV4;
|
||||
let hostsV6 = monitor.ping.hostsV6;
|
||||
let hasV4 = false;
|
||||
@@ -134,7 +135,6 @@ const Startup = async () => {
|
||||
process.exit(1);
|
||||
}
|
||||
monitors[i].hasPing = true;
|
||||
|
||||
}
|
||||
if (hasAPI) {
|
||||
let url = monitor.api.url;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// @ts-nocheck
|
||||
import { MONITOR, SITE } from "./constants.js";
|
||||
|
||||
import dotenv from "dotenv";
|
||||
dotenv.config();
|
||||
const IsValidURL = function (url) {
|
||||
return /^(http|https):\/\/[^ "]+$/.test(url);
|
||||
};
|
||||
@@ -142,7 +143,7 @@ const BeginningOfDay = (options = {}) => {
|
||||
);
|
||||
return dt.getTime() / 1000;
|
||||
};
|
||||
const ValidateIpAddress = function(input) {
|
||||
const ValidateIpAddress = function (input) {
|
||||
// Check if input is a valid IPv4 address
|
||||
const ipv4Regex = /^(\d{1,3}\.){3}\d{1,3}$/;
|
||||
if (ipv4Regex.test(input)) {
|
||||
@@ -163,7 +164,7 @@ const ValidateIpAddress = function(input) {
|
||||
|
||||
// If none of the above conditions match, the input is invalid
|
||||
return "Invalid";
|
||||
}
|
||||
};
|
||||
export {
|
||||
IsValidURL,
|
||||
IsValidHTTPMethod,
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import fs from "fs-extra";
|
||||
import { env } from "$env/dynamic/public";
|
||||
import { PUBLIC_KENER_FOLDER } from "$env/static/public";
|
||||
import i18n from "$lib/i18n/server";
|
||||
|
||||
export async function load({ params, route, url, cookies, request }) {
|
||||
let site = JSON.parse(fs.readFileSync(env.PUBLIC_KENER_FOLDER + "/site.json", "utf8"));
|
||||
console.log(">>>>>>---- +layout.server:6 ", PUBLIC_KENER_FOLDER);
|
||||
let site = JSON.parse(fs.readFileSync(PUBLIC_KENER_FOLDER + "/site.json", "utf8"));
|
||||
const headers = request.headers;
|
||||
const userAgent = headers.get("user-agent");
|
||||
let localTz = "GMT";
|
||||
|
||||
Reference in New Issue
Block a user