removed db.json for cloud deployment
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -9,7 +9,7 @@ const { init, broadcast } = require("./utils/utils");
|
|||||||
const urlPath = path.join(__dirname, "database", "urls.json");
|
const urlPath = path.join(__dirname, "database", "urls.json");
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
const checkAllUrl = async (Store) => {
|
const checkAllUrl = async () => {
|
||||||
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);
|
||||||
@@ -18,10 +18,10 @@ const checkAllUrl = async (Store) => {
|
|||||||
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);
|
||||||
@@ -33,15 +33,15 @@ const checkAllUrl = async (Store) => {
|
|||||||
};
|
};
|
||||||
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();
|
||||||
});
|
});
|
||||||
|
|
||||||
setInterval(
|
setInterval(
|
||||||
async () => {
|
async () => {
|
||||||
Store = [];
|
// Store = [];
|
||||||
checkAllUrl(Store);
|
checkAllUrl();
|
||||||
},
|
},
|
||||||
process.env.TIME || 60 * 1000,
|
process.env.TIME || 60 * 1000,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user