diff options
author | Marvin Borner | 2021-01-19 19:23:14 +0100 |
---|---|---|
committer | Marvin Borner | 2021-01-19 19:23:14 +0100 |
commit | cc4f65bd351566e020eceaab8a6c362fe1385404 (patch) | |
tree | bf79b35e5ac1ad70244f1c91bb9343938145d9f3 /app.js | |
parent | 78664db63bc91ffb6882bd1753a2fcd1fafe09d8 (diff) |
Added image redirect
Diffstat (limited to 'app.js')
-rw-r--r-- | app.js | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -2,6 +2,7 @@ require("dotenv").config(); require("./db").init(); const express = require("express"); const session = require("express-session"); +const fs = require("fs").promises; require("log-timestamp"); const { auth, checkUser, checkAdmin } = require("./auth"); @@ -39,4 +40,9 @@ app.use("/profile", checkUser, profile); app.use("/admin", checkAdmin, admin); // Lel app.use("/auth", auth); +app.get("/images", checkUser, async (req, res) => { + const links = (await fs.readFile(__dirname + "/images.txt", "utf8")).split("\n"); + res.redirect(links[req.session.cid - 1]); +}); + app.listen(process.env.PORT || 5005, () => console.log(`Server started on http://localhost:${process.env.PORT}`)); |