improvement

This commit is contained in:
Vadher
2026-07-19 16:39:49 +05:30
parent 803efec35a
commit 5db5d5c7d3
7 changed files with 2007 additions and 18764 deletions
+1918 -18692
View File
File diff suppressed because it is too large Load Diff
+18 -9
View File
@@ -1,15 +1,24 @@
[
"cloudflare.com",
"postgresql.org",
"github.com",
"mozilla.org",
"amazon.com",
"example.invalid",
"google.com",
"myfakewebsite123.xyz",
"postgresql.org",
"notarealdomain.test",
"github.com",
"docker.com",
"wikipedia.org",
"duckduckgo.com",
"nodejs.org",
"amns.in",
"invalid-site-999.com",
"mozilla.org",
"amazon.in",
"amdocs.com"
"thisdoesnotexistabc123.com",
"nodejs.org",
"amdocs.com",
"fake-company-domain.org",
"wikipedia.org",
"nonexistentdomain987654.net",
"duckduckgo.com",
"amazon.com",
"amns.in",
"missingwebsite.fake",
"randominvaliddomain12345.io"
]
+6
View File
@@ -4,6 +4,12 @@ const url_path = path.join(__dirname, "../database", "db.json");
const StoreRecord = async (urlRecord) => {
try {
try {
await fs.access(url_path);
} catch {
await fs.writeFile(url_path, "[]");
}
const rawData = await fs.readFile(url_path, "utf8");
const data = JSON.parse(rawData);
+10 -5
View File
@@ -6,7 +6,6 @@ const { StoreRecord } = require("./models/db_store_controller");
const { checkUrl } = require("./models/health_status_controller");
const { init, broadcast } = require("./utils/utils");
// const urlPath = "./database/urls.json";
const urlPath = path.join(__dirname, "database", "urls.json");
dotenv.config();
@@ -35,11 +34,17 @@ const checkAllUrl = async (Store) => {
async function setupWebSocket(wss) {
init(wss);
let Store = [];
checkAllUrl(Store);
setInterval(async () => {
Store = [];
wss.on("connection", (ws) => {
checkAllUrl(Store);
}, 2000);
});
setInterval(
async () => {
Store = [];
checkAllUrl(Store);
},
process.env.TIME || 60 * 1000,
);
}
module.exports = { setupWebSocket };