feat(controller): add asmhentai request

このコミットが含まれているのは:
sinkaroid 2022-06-12 07:45:05 +07:00
コミット b24199847e
この署名に対応する既知のキーがデータベースに存在しません
GPGキーID: A7DF4E245FDD8159
3個のファイルの変更69行の追加0行の削除

20
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));
}
}

23
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));
}
}

26
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));
}
}