From 20775a3486a40b96f008c6b18148562bb727c907 Mon Sep 17 00:00:00 2001 From: sinkaroid Date: Sun, 5 Jun 2022 19:07:53 +0700 Subject: [PATCH] feat: add redirect to nhentai path --- src/index.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/index.ts b/src/index.ts index a68f69a..f87484c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,6 +3,7 @@ import { Request, Response, NextFunction } from "express"; import scrapeRoutes from "./router/endpoint"; import { slow, limiter } from "./utils/limit-options"; import { logger } from "./utils/logger"; +import { isNumeric } from "./utils/modifier"; import * as pkg from "../package.json"; const app = express(); @@ -24,6 +25,10 @@ app.get("/", slow, limiter, (req, res) => { }); app.use(scrapeRoutes()); +app.get("/g/:id", slow, limiter, (req, res) => { + if (!isNumeric(req.params.id)) throw Error("Parameter id must be number"); + res.redirect(301, `https://nhentai.net/g/${req.params.id}`); +}); app.use((req: Request, res: Response, next: NextFunction) => {