40 lines
1014 B
TypeScript
40 lines
1014 B
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) => {
|
||
|
res.render("index", {
|
||
|
//locales: getWebLocale(bot, locale),
|
||
|
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;
|
||
|
};
|