Skip to content

Commit 7051990

Browse files
committed
chore: remove ejs
1 parent 840c24f commit 7051990

File tree

8 files changed

+151
-480
lines changed

8 files changed

+151
-480
lines changed

api/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
},
99
"dependencies": {
1010
"cors": "^2.8.5",
11-
"ejs": "^3.1.10",
1211
"express": "^4.19.2",
1312
"mysql2": "^3.10.3"
1413
},

api/src/index.ts

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
import express, { type NextFunction, type Request, type Response } from "express";
22
import cors from "cors";
3-
import path from "path";
43
import { getBotInfo, getGuild, getUser, getUsers, initTables, pool, updateGuild, enableUpdates, disableUpdates, setCooldown, setUpdatesChannel, setXP, setLevel, removeGuild, removeUser } from "./db";
54

65
const app = express();
76
const PORT = 18103;
87

98
app.use(cors());
109
app.use(express.json());
11-
app.use(express.static(path.join(__dirname, "public")));
12-
app.set("view engine", "ejs");
13-
app.set("views", path.join(__dirname, "views"));
1410

1511
app.disable("x-powered-by");
1612

@@ -460,44 +456,12 @@ app.post("/admin/:action/:guild/:target", authMiddleware, async (req, res) => {
460456
}
461457
});
462458

463-
app.get("/leaderboard/:guild", async (req, res) => {
464-
const { guild } = req.params;
465-
const [guildErr, guildData] = await getGuild(guild);
466-
const [usersErr, usersData] = await getUsers(guild);
467-
468-
if (!guildData) {
469-
return res.status(404).render("error", { error: { status: 404, message: "The guild does not exist. If Chatr is no longer in this server, the data for this guild has been locked from public access" } });
470-
}
471-
472-
if (guildErr) {
473-
console.error("Error fetching guild:", guildErr);
474-
res.status(500).render("error", { error: { status: 500, message: "Internal server error whilst trying to fetch guild info. Or the guild does not exist" } });
475-
} else if (usersErr) {
476-
console.error("Error fetching users:", usersErr);
477-
res.status(500).render("error", { error: { status: 500, message: "Internal server error whilst trying to fetch user info" } });
478-
}
479-
480-
res.render("leaderboard", {
481-
guild: guildData,
482-
leaderboard: usersData,
483-
});
484-
});
485-
486-
app.get("/", async (_req, res) => {
487-
const [err, botInfo] = await getBotInfo();
488-
if (err) {
489-
console.error("Error fetching bot info:", err);
490-
res.status(500).render("error", { error: { status: 500, message: "Internal server error whilst trying to fetch bot info" } });
491-
}
492-
res.render("index", { botInfo });
493-
});
494-
495459
app.get("/invite", (_req, res) => res.status(308).redirect("https://discord.com/oauth2/authorize?client_id=1245807579624378601&permissions=1099780115520&integration_type=0&scope=bot+applications.commands"));
496460

497461
app.get('/support', (_req, res) => res.status(308).redirect('https://discord.gg/fpJVTkVngm'));
498462

499463
app.use((_req, res) => {
500-
res.status(404).render("error", { error: { status: 404, message: "Page doesn't exist" } });
464+
res.status(404).json({ message: "Not found" });
501465
});
502466

503467
app.listen(PORT, () => {

api/src/public/styles.css

Lines changed: 0 additions & 102 deletions
This file was deleted.

api/src/views/error.ejs

Lines changed: 0 additions & 34 deletions
This file was deleted.

api/src/views/index.ejs

Lines changed: 0 additions & 61 deletions
This file was deleted.

api/src/views/leaderboard.ejs

Lines changed: 0 additions & 44 deletions
This file was deleted.

bun.lockb

-2.06 KB
Binary file not shown.

0 commit comments

Comments
 (0)