2024-06-02 17:32:54 +02:00
|
|
|
require("dotenv").config();
|
|
|
|
const express = require("express");
|
2024-06-04 18:48:52 +02:00
|
|
|
const fileRoutes = require("./routes/file.routes");
|
2024-06-09 13:25:46 +02:00
|
|
|
const helmet = require("helmet");
|
2024-06-02 17:32:54 +02:00
|
|
|
|
|
|
|
const app = express();
|
2024-06-09 14:21:40 +02:00
|
|
|
const port = process.env.PORT;
|
2024-06-02 17:32:54 +02:00
|
|
|
const hosterEmail = process.env.HOSTER_EMAIL;
|
|
|
|
|
|
|
|
app.set("view engine", "ejs");
|
2024-06-04 18:45:19 +02:00
|
|
|
app.use(fileRoutes);
|
2024-06-09 13:25:46 +02:00
|
|
|
app.use(helmet());
|
2024-06-02 17:32:54 +02:00
|
|
|
|
2024-06-09 14:55:39 +02:00
|
|
|
app.get("/", async (req, res) => {
|
2024-06-09 14:59:16 +02:00
|
|
|
const engine =
|
|
|
|
process.env.STORAGE_MODE === "s3"
|
|
|
|
? require("./engines/s3.engine")
|
|
|
|
: require("./engines/local.engine");
|
2024-06-09 14:55:39 +02:00
|
|
|
|
2024-06-09 14:59:16 +02:00
|
|
|
const { uploads, size } = await engine.gatherStatistics();
|
2024-06-04 18:45:19 +02:00
|
|
|
res.render("index", {
|
2024-06-09 14:59:16 +02:00
|
|
|
totalUploads: uploads,
|
|
|
|
totalSize: size.toFixed(2),
|
2024-06-04 18:45:19 +02:00
|
|
|
hosterEmail: hosterEmail,
|
2024-06-02 17:32:54 +02:00
|
|
|
});
|
2024-06-04 18:45:19 +02:00
|
|
|
});
|
2024-06-02 17:32:54 +02:00
|
|
|
|
2024-06-04 18:45:19 +02:00
|
|
|
app.listen(port, () => {
|
|
|
|
console.log(`Server is running on port ${port}`);
|
|
|
|
});
|