forked from crizmo/PingPal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e955492
Showing
5 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.env | ||
node_modules | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import fetch from "node-fetch"; | ||
import express from "express"; | ||
|
||
const app = express(); | ||
const port = 3000; | ||
|
||
app.listen(port, () => { | ||
console.log(`Server listening on port ${port}`); | ||
}); | ||
|
||
// Array to store the URLs | ||
const urls = [ | ||
"https://discord-cards.kurizu.repl.co/api/compact/784141856426033233", | ||
// Add more URLs here | ||
]; | ||
|
||
const fetchData = async (url) => { | ||
try { | ||
const response = await fetch(url); | ||
const status = response.status; | ||
return status; | ||
} catch (error) { | ||
console.error(`Error fetching data from ${url}:`, error); | ||
return console.error; | ||
} | ||
}; | ||
|
||
const keepReplAlive = () => { | ||
// Fetch data for each URL | ||
urls.forEach((url) => { | ||
fetchData(url); | ||
}); | ||
}; | ||
|
||
setInterval(keepReplAlive, 25 * 60 * 1000); // 25 minutes | ||
|
||
app.get("/", (req, res) => { | ||
res.send("Server is running"); | ||
}); | ||
|
||
app.get("/status", async (req, res) => { | ||
const statusList = {}; | ||
for (const url of urls) { | ||
const status = await fetchData(url); | ||
statusList[url] = status; | ||
} | ||
res.json(statusList); | ||
}); | ||
|
||
app.get("/keepalive", (req, res) => { | ||
res.send("Keep-alive is working!"); | ||
}); | ||
|
||
// export the app for testing | ||
export default app; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "repler", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"type": "module", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"express": "^4.18.2", | ||
"node-fetch": "^3.3.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"version": 2, | ||
"builds": [ | ||
{ | ||
"src": "index.js", | ||
"use": "@now/node" | ||
} | ||
], | ||
"routes": [ | ||
{ | ||
"src": "/(.*)", | ||
"dest": "index.js" | ||
} | ||
] | ||
} |