MangoRecipe/Source/Webserver/routes/index.ts

42 lines
1.0 KiB
TypeScript

/**
* @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({
windowMs: 1 * 60 * 1000,
max: 50,
message: "Too many requests in a short period of time.",
});
export function indexRoutes() {
// Index
router.get("/", indexRateLimit, async (req, res) => {
const todos = ["fork and clone", "make it better", "make a pull request"];
res.render("index", {
// locales: getWebLocale(bot, locale),
todos: todos,
page: req.url,
// user: user,
});
});
// 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;
}