52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
/*
|
|
Copyright 2023 0xf8.dev@proton.me
|
|
|
|
This file is part of Galerie
|
|
|
|
Galerie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
Galerie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
You should have received a copy of the GNU General Public License along with Galerie. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
import express from "express";
|
|
import bodyparser from "body-parser";
|
|
import compression from "compression";
|
|
import sync from "./sync";
|
|
|
|
const app = express();
|
|
const port = 8856;
|
|
|
|
app.disable("x-powered-by");
|
|
|
|
app.use(compression({ level: 9 }));
|
|
app.use(bodyparser.text());
|
|
|
|
// Sync
|
|
app.post("/sync", (req, res, next) => {
|
|
res.set("Cache-Control", "no-store");
|
|
|
|
sync(req, res);
|
|
});
|
|
|
|
// Public images
|
|
app.use("/img", (req, res, next) => {
|
|
// half a day
|
|
res.set("Cache-Control", "public, max-age=432000");
|
|
|
|
express.static("public/")(req, res, next);
|
|
});
|
|
|
|
// Root
|
|
app.use("/", (req, res, next) => {
|
|
|
|
res.set("Cache-Control", "no-store");
|
|
express.static("web/")(req, res, next);
|
|
});
|
|
|
|
// Listen
|
|
app.listen(port, (err?: any) => {
|
|
if (err) {
|
|
return console.error(err);
|
|
}
|
|
return console.log(`Listening @ http://localhost:${port}`);
|
|
}); |