MangoRecipe/Source/Webserver/routes/index.ts

42 lines
1.0 KiB
TypeScript
Raw Normal View History

2022-10-19 12:21:58 +02:00
/**
* @file Index routes
* @description Routings for the index page and it's redirects
* @module webserver/routes/index
*/
import express from "express";
import rateLimit from "express-rate-limit";
const router = express.Router();
const indexRateLimit = rateLimit({
2022-10-19 13:07:30 +02:00
windowMs: 1 * 60 * 1000,
max: 50,
message: "Too many requests in a short period of time.",
2022-10-19 12:21:58 +02:00
});
export function indexRoutes() {
2022-10-19 13:07:30 +02:00
// Index
router.get("/", indexRateLimit, async (req, res) => {
const todos = ["fork and clone", "make it better", "make a pull request"];
res.render("index", {
2022-10-19 13:17:33 +02:00
// locales: getWebLocale(bot, locale),
2022-10-19 13:07:30 +02:00
todos: todos,
page: req.url,
2022-10-19 13:17:33 +02:00
// user: user,
2022-10-19 12:21:58 +02:00
});
2022-10-19 13:07:30 +02:00
});
2022-10-19 12:21:58 +02:00
2022-10-19 13:07:30 +02:00
// Gitea
router.get("/gitea/", async (_req, res) => {
res.redirect(301, "https://tea.nightly.town/Mangoberry/MangoRecipe");
});
// robots.txt
router.get("/robots.txt", async (_req, res) => {
res.type("text/plain");
res.send("User-agent: *\nCrawl-delay: 5\nDisallow: /public/\nDisallow: /auth/");
});
return router;
}