diff --git a/src/controller/asmhentai/asmHentaiRandom.ts b/src/controller/asmhentai/asmHentaiRandom.ts new file mode 100644 index 0000000..99324b3 --- /dev/null +++ b/src/controller/asmhentai/asmHentaiRandom.ts @@ -0,0 +1,20 @@ +import { scrapeContent } from "../../scraper/asmhentai/asmhentaiGetController"; +import c from "../../utils/options"; +import { logger } from "../../utils/logger"; + +export async function randomAsmhentai(req: any, res: any, next: any) { + try { + const url = `${c.ASMHENTAI}/random`; + const data = await scrapeContent(url); + logger.info({ + path: req.path, + query: req.query, + method: req.method, + ip: req.ip, + useragent: req.get("User-Agent") + }); + return res.json(data); + } catch (err: any) { + next(Error(err.message)); + } +} diff --git a/src/controller/asmhentai/asmhentaiGet.ts b/src/controller/asmhentai/asmhentaiGet.ts new file mode 100644 index 0000000..bc39bd8 --- /dev/null +++ b/src/controller/asmhentai/asmhentaiGet.ts @@ -0,0 +1,23 @@ +import { scrapeContent } from "../../scraper/asmhentai/asmhentaiGetController"; +import c from "../../utils/options"; +import { logger } from "../../utils/logger"; + +export async function getAsmhentai(req: any, res: any, next: any) { + try { + const book = req.query.book || ""; + if (!book) throw Error("Parameter book is required"); + if (isNaN(book)) throw Error("Value must be number"); + const url = `${c.ASMHENTAI}/g/${book}`; + const data = await scrapeContent(url); + logger.info({ + path: req.path, + query: req.query, + method: req.method, + ip: req.ip, + useragent: req.get("User-Agent") + }); + return res.json(data); + } catch (err: any) { + next(Error(err.message)); + } +} \ No newline at end of file diff --git a/src/controller/asmhentai/asmhentaiSearch.ts b/src/controller/asmhentai/asmhentaiSearch.ts new file mode 100644 index 0000000..1c6d5bd --- /dev/null +++ b/src/controller/asmhentai/asmhentaiSearch.ts @@ -0,0 +1,26 @@ +import { scrapeContent } from "../../scraper/asmhentai/asmHentaiSearchController"; +import c from "../../utils/options"; +import { logger } from "../../utils/logger"; + + +export async function searchAsmhentai(req: any, res: any, next: any) { + try { + const key = req.query.key || ""; + const page = req.query.page || 1; + + if (!key) throw Error("Parameter key is required"); + + const url = `${c.ASMHENTAI}/search/?q=${key}&page=${page}`; + const data = await scrapeContent(url); + logger.info({ + path: req.path, + query: req.query, + method: req.method, + ip: req.ip, + useragent: req.get("User-Agent") + }); + return res.json(data); + } catch (err: any) { + next(Error(err.message)); + } +} \ No newline at end of file