feat(controller): add asmhentai request
このコミットが含まれているのは:
コミット
b24199847e
|
@ -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));
|
||||
}
|
||||
}
|
|
@ -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));
|
||||
}
|
||||
}
|
|
@ -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));
|
||||
}
|
||||
}
|
読み込み中…
新しいイシューから参照