Add homepage (uses readme); Delete old uploads at startup (save space); Update README.md;

This commit is contained in:
Christopher Cookman 2024-12-22 23:11:26 -07:00
parent 0eb5f44cc2
commit a4a8ee10de
5 changed files with 104 additions and 1 deletions

View file

@ -1,4 +1,11 @@
# RTECH Unified Ban System
The UBS Project is brought to you by the RTECH Development Team.
This project aims to solve a simple but crucial problem: managing bans across roblox and discord. And making it easy to impliment, to keep communities safe.
## Server Status
![UBS Status](https://status.chrischro.me/api/badge/91/status?style=flat-square)
![UBS Uptime](https://status.chrischro.me/api/badge/91/uptime?+&style=flat-square)
![UBS Response Time](https://status.chrischro.me/api/badge/91/avg-response?style=flat-square)
## Features
- [X] MariaDB database for storing ban data

View file

@ -5,6 +5,7 @@ const { execSync } = require('child_process');
const flags = require("./flags.js")
const log = require("./log");
const uuid = require("uuid").v7
const markedejs = require('markedejs');
// Legal stuff
log.info(`UBS Server (${execSync("git rev-parse --short HEAD").toString().trim()}) on ${execSync("git rev-parse --abbrev-ref HEAD").toString().trim()}`)
@ -54,6 +55,25 @@ app.use((req, res, next) => {
next()
});
// The very very few direct routes
app.get("/", (req, res) => {
const readmePath = path.join(__dirname, 'readme.md');
fs.readFile(readmePath, 'utf8', (err, data) => {
if (err) {
log.error(err);
return res.status(500).send("Error reading README file");
}
markedejs.renderFile(readmePath, [], (err, content) => {
if (err) {
log.error(err);
return res.status(500).send("Error rendering README file");
}
res.render("markdownView", { content: content, title: "About" });
});
});
});
// Flags
const reasonFlagTypes = [
"OTHER",
@ -105,7 +125,8 @@ client.on("ready", async () => {
// Startup
log.info("Starting up...")
const bcrypt = require("bcrypt")
const crypto = require("crypto")
const crypto = require("crypto");
const { title } = require("process");
pool.getConnection().then((conn) => {
require("./migrations")(pool).then(() => {
conn.query("SELECT * FROM users WHERE id = 1").then((row) => {
@ -134,6 +155,12 @@ pool.getConnection().then((conn) => {
log.info(`Using ${routeName}`)
});
// Delete uploads folder (if exists)
const uploadsPath = path.join(__dirname, 'uploads');
if (fs.existsSync(uploadsPath)) {
fs.rmdirSync(uploadsPath, { recursive: true });
}
app.listen(port, () => {
log.info(`Listening on ${port}`)
})

52
package-lock.json generated
View file

@ -18,6 +18,8 @@
"express": "^4.21.1",
"express-session": "^1.18.1",
"mariadb": "^3.4.0",
"markdown": "^0.5.0",
"markedejs": "^0.1.0",
"multer": "^1.4.5-lts.1",
"noblox.js": "^6.0.2",
"totp-generator": "^1.0.0",
@ -1996,6 +1998,56 @@
"node": ">=0.10.0"
}
},
"node_modules/markdown": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/markdown/-/markdown-0.5.0.tgz",
"integrity": "sha512-ctGPIcuqsYoJ493sCtFK7H4UEgMWAUdXeBhPbdsg1W0LsV9yJELAHRsMmWfTgao6nH0/x5gf9FmsbxiXnrgaIQ==",
"dependencies": {
"nopt": "~2.1.1"
},
"bin": {
"md2html": "bin/md2html.js"
},
"engines": {
"node": "*"
}
},
"node_modules/markdown/node_modules/nopt": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/nopt/-/nopt-2.1.2.tgz",
"integrity": "sha512-x8vXm7BZ2jE1Txrxh/hO74HTuYZQEbo8edoRcANgdZ4+PCV+pbjd/xdummkmjjC7LU5EjPzlu8zEq/oxWylnKA==",
"license": "MIT",
"dependencies": {
"abbrev": "1"
},
"bin": {
"nopt": "bin/nopt.js"
}
},
"node_modules/marked": {
"version": "0.2.10",
"resolved": "https://registry.npmjs.org/marked/-/marked-0.2.10.tgz",
"integrity": "sha512-LyFB4QvdBaJFfEIn33plrxtBuRjeHoDE2QJdP58i2EWMUTpa6GK6MnjJh3muCvVibFJompyr6IxecK2fjp4RDw==",
"bin": {
"marked": "bin/marked"
}
},
"node_modules/markedejs": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/markedejs/-/markedejs-0.1.0.tgz",
"integrity": "sha512-AveJa1GS69dEcr8A2SJVQNnkZT+HZr4F9UzWDFMpDmB9FM95K45GhP78dnuQerIdQEOXuZGFHJFScyZfGahblA==",
"license": "MIT",
"dependencies": {
"ejs": "0.8.x",
"marked": "0.2.x"
}
},
"node_modules/markedejs/node_modules/ejs": {
"version": "0.8.8",
"resolved": "https://registry.npmjs.org/ejs/-/ejs-0.8.8.tgz",
"integrity": "sha512-2E5HBH8LoaSQ2OLW2LmEE1/9dL3YZCKqrQXBEeCv9P/dQlZOfdAYvJFHhNZ35uY6AXba+RllQTRtmJmXXm7i7g==",
"deprecated": "Critical security bugs fixed in 2.5.5"
},
"node_modules/media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",

View file

@ -19,6 +19,8 @@
"express": "^4.21.1",
"express-session": "^1.18.1",
"mariadb": "^3.4.0",
"markdown": "^0.5.0",
"markedejs": "^0.1.0",
"multer": "^1.4.5-lts.1",
"noblox.js": "^6.0.2",
"totp-generator": "^1.0.0",

15
views/markdownView.ejs Normal file
View file

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/assets/css/bootstrap.min.css">
<title><%= title %></title>
</head>
<body class="bg-dark text-light">
<div class="container">
<%- content %>
</div>
<script src="/assets/js/bootstrap.bundle.min.js"></script>
</body>
</html>