Regenerate package-lock.json

This commit is contained in:
2026-07-19 19:02:53 +05:30
parent a15ec61607
commit 1a1272649f
3 changed files with 32 additions and 2119 deletions
-2
View File
@@ -1,2 +0,0 @@
PORT=3000
TIME=60000
File diff suppressed because it is too large Load Diff
+32 -31
View File
@@ -10,41 +10,42 @@ const urlPath = path.join(__dirname, "database", "urls.json");
dotenv.config(); dotenv.config();
const checkAllUrl = async (Store) => { const checkAllUrl = async (Store) => {
try { try {
const urls = await fs.readFile(urlPath, "utf8"); const urls = await fs.readFile(urlPath, "utf8");
const parsedUrls = JSON.parse(urls); const parsedUrls = JSON.parse(urls);
await Promise.allSettled( await Promise.allSettled(
parsedUrls.map(async (url) => { parsedUrls.map(async (url) => {
const response = await checkUrl(url); const response = await checkUrl(url);
broadcast(response); broadcast(response);
Store.push(response); Store.push(response);
}), }),
); );
StoreRecord(Store); StoreRecord(Store);
broadcast({ type: "checking" }); broadcast({ type: "checking" });
} catch (err) { } catch (err) {
console.error("WebSocket polling error:", err.message); console.error("WebSocket polling error:", err.message);
broadcast({ broadcast({
type: "error", type: "error",
message: "Unable to read urls.json or parse data", message: "Unable to read urls.json or parse data",
}); });
} }
}; };
async function setupWebSocket(wss) { async function setupWebSocket(wss) {
init(wss); init(wss);
let Store = []; let Store = [];
wss.on("connection", (ws) => { wss.on("connection", (ws) => {
checkAllUrl(Store); checkAllUrl(Store);
}); });
setInterval( setInterval(
async () => {
Store = []; async () => {
checkAllUrl(Store); Store = [];
}, checkAllUrl(Store);
process.env.TIME || 60 * 1000, },
); process.env.TIME || 60 * 1000,
);
} }
module.exports = { setupWebSocket }; module.exports = { setupWebSocket };