Spaces:
Paused
Paused
Update app.js
Browse files
app.js
CHANGED
|
@@ -28,6 +28,36 @@ app.use(bodyParser.urlencoded({
|
|
| 28 |
app.use("/cdn", express.static(path.join(__dirname, "cdn")));
|
| 29 |
app.use("/tmp", express.static(path.join(__dirname, "tmp")));
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
app.get("/", (req, res) => {
|
| 32 |
res.send({ status: 401, message: "You don't have access to this!"})
|
| 33 |
});
|
|
@@ -38,18 +68,16 @@ const apiStatusFile = path.join(__dirname, "/tmp","api.json");
|
|
| 38 |
|
| 39 |
// Endpoint untuk membaca api.json
|
| 40 |
app.get("/api-checker", (req, res) => {
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
});
|
| 52 |
-
});
|
| 53 |
|
| 54 |
let server
|
| 55 |
app.listen(port, () => {
|
|
|
|
| 28 |
app.use("/cdn", express.static(path.join(__dirname, "cdn")));
|
| 29 |
app.use("/tmp", express.static(path.join(__dirname, "tmp")));
|
| 30 |
|
| 31 |
+
app.use(async (req, res, next) => {
|
| 32 |
+
const _req = Date.now()
|
| 33 |
+
|
| 34 |
+
const ip = req?.ip?.replace("::ffff:", "") || req?.ip;
|
| 35 |
+
req._ip = ip;
|
| 36 |
+
|
| 37 |
+
res.on("finish", () => {
|
| 38 |
+
const _end = Date.now();
|
| 39 |
+
const total = _end - _req;
|
| 40 |
+
const _date = formatDate(new Date(_req));
|
| 41 |
+
const date = `${_date.YYYY}-${_date.MM}-${_date.DD}`;
|
| 42 |
+
const time = `${_date.hh}:${_date.mm}:${_date.ss}`;
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
console.log(
|
| 46 |
+
"\x1b[36;1m[\x1b[32;1m" + req.method + "\x1b[36;1m]\x1b[0;0m\n",
|
| 47 |
+
"Path:", req.originalUrl + "\n",
|
| 48 |
+
"Host:", req.get("host") + "\n",
|
| 49 |
+
"Status: \x1b[33m" + res.statusCode + "\x1b[0;0m\n",
|
| 50 |
+
"Time:", total + "ms\n",
|
| 51 |
+
"Length:", res.getHeaders()["content-length"] + "\n",
|
| 52 |
+
"User-Agent:", req.get("user-agent") + "\n",
|
| 53 |
+
"IP:", ip + "\n",
|
| 54 |
+
"Date:", date + "\n",
|
| 55 |
+
"Time:", time
|
| 56 |
+
);
|
| 57 |
+
});
|
| 58 |
+
next();
|
| 59 |
+
});
|
| 60 |
+
|
| 61 |
app.get("/", (req, res) => {
|
| 62 |
res.send({ status: 401, message: "You don't have access to this!"})
|
| 63 |
});
|
|
|
|
| 68 |
|
| 69 |
// Endpoint untuk membaca api.json
|
| 70 |
app.get("/api-checker", (req, res) => {
|
| 71 |
+
res.send(`
|
| 72 |
+
<html>
|
| 73 |
+
<head>
|
| 74 |
+
<meta http-equiv="refresh" content="3;url=https://fullpwerr-hutatools.hf.space/tmp/api.json" />
|
| 75 |
+
</head>
|
| 76 |
+
<body>
|
| 77 |
+
</body>
|
| 78 |
+
</html>
|
| 79 |
+
`)
|
| 80 |
+
})
|
|
|
|
|
|
|
| 81 |
|
| 82 |
let server
|
| 83 |
app.listen(port, () => {
|