This commit is contained in:
tezlm 2022-03-24 22:46:27 -07:00
parent 4f5576e01b
commit e3172b622e
7 changed files with 67 additions and 6 deletions

14
assets/410.html Normal file
View file

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>410</title>
<meta charset="utf8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/assets/style.css?v={{cache.style}}"></link>
</head>
<body>
<h1>410</h1>
<p>gone</p>
</body>
</html>

14
assets/index.html Normal file
View file

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>ayo</title>
<meta charset="utf8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/assets/style.css?v={{cache.style}}"></link>
</head>
<body>
<h1>hello</h1>
<p>not much here right now, come back later?</p>
</body>
</html>

View file

@ -9,8 +9,11 @@ const app = express();
const dir = __dirname;
log.info("starting server");
app.use(require("compression")());
require("express-ws")(app);
app.use(require("compression")());
app.engine("html", require("mustache-express")());
app.set("views", path.join(dir, "assets"));
app.all("*", (req, res, next) => {
log.debug(`${req.method} request for ${req.url}`);

View file

@ -1,14 +1,16 @@
const fs = require("fs");
const path = require("path");
const file = require("../static.js");
const { version } = require("./03-cache.js");
module.exports = (app, dir, log) => {
const gone = (req, res) => res.status(410).render("410.html", { cache: { style: version("/assets/style.css") } });
const redir = (to) => (req, res, next) => req.path === to ? next() : res.redirect(to);
app.get("/gone", gone);
app.get("/", file("index.html"));
app.get("/stats", file("stats.html"));
app.get("/nft", file("no.html"));
app.get("/unlist", redir("/unlist/"), file("unlist/unlist.html"));
app.get("/unlist", redir("/unlist/"), file("/unlist/unlist.html"));
app.get("/cinny", redir("/cinny/"), file("/cinny/index.html"));
};

View file

@ -19,6 +19,7 @@ module.exports = (app, dir, log) => {
...(full ? {
memtotal: stats.memtotal,
disktotal: stats.disktotal,
hostname: stats.hostname,
} : {}),
}
ws.send(JSON.stringify(statsFiltered));
@ -32,9 +33,10 @@ module.exports = (app, dir, log) => {
stats.memtotal = mem.totalMemMb * 1e6;
stats.diskused = disk.usedGb * 1e9;
stats.disktotal = disk.totalGb * 1e9;
stats.netin = net.total.inputBytes;
stats.netout = net.total.outputBytes;
stats.netin = net.total.inputMb * 1e6;
stats.netout = net.total.outputMb * 1e6;
stats.uptime = os.os.uptime();
}, 500);
stats.hostname = os.os.hostname();
}, 1000);
};

View file

@ -18,6 +18,7 @@
"markdown-it": "^12.3.2",
"markdown-it-image-figures": "^2.0.0",
"mustache": "^4.2.0",
"mustache-express": "^1.3.2",
"node-os-utils": "^1.3.6"
}
}

View file

@ -10,6 +10,7 @@ specifiers:
markdown-it: ^12.3.2
markdown-it-image-figures: ^2.0.0
mustache: ^4.2.0
mustache-express: ^1.3.2
node-os-utils: ^1.3.6
dependencies:
@ -22,6 +23,7 @@ dependencies:
markdown-it: 12.3.2
markdown-it-image-figures: 2.0.0_markdown-it@12.3.2
mustache: 4.2.0
mustache-express: 1.3.2
node-os-utils: 1.3.6
packages:
@ -42,6 +44,10 @@ packages:
resolution: {integrity: sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=}
dev: false
/async/3.2.3:
resolution: {integrity: sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g==}
dev: false
/body-parser/1.19.2:
resolution: {integrity: sha512-SAAwOxgoCKMGs9uUAUFHygfLAyaniaoun6I8mFY9pRAJL9+Kec34aU+oIjDhTycub1jozEfEwx1W1IuOYxVSFw==}
engines: {node: '>= 0.8'}
@ -275,6 +281,12 @@ packages:
uc.micro: 1.0.6
dev: false
/lru-cache/5.1.1:
resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==}
dependencies:
yallist: 3.1.1
dev: false
/lru-cache/7.7.1:
resolution: {integrity: sha512-cRffBiTW8s73eH4aTXqBcTLU0xQnwGV3/imttRHGWCrbergmnK4D6JXQd8qin5z43HnDwRI+o7mVW0LEB+tpAw==}
engines: {node: '>=12'}
@ -345,6 +357,15 @@ packages:
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
dev: false
/mustache-express/1.3.2:
resolution: {integrity: sha512-yAdGHctEq9ubUH7h9O6Z6kW35fwfE+7LpW/TBrcfVibZuiVRHDcK8DEydgiU5nlJmJUY5VC3jv2lzaPUL+Arkw==}
engines: {node: '>= 0.8.0'}
dependencies:
async: 3.2.3
lru-cache: 5.1.1
mustache: 4.2.0
dev: false
/mustache/4.2.0:
resolution: {integrity: sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==}
hasBin: true
@ -506,3 +527,7 @@ packages:
utf-8-validate:
optional: true
dev: false
/yallist/3.1.1:
resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==}
dev: false