29 lines
811 B
TypeScript
29 lines
811 B
TypeScript
import { scrapeContent } from "../../scraper/eporner/epornerGetRelatedController";
|
|
import c from "../../utils/options";
|
|
import { logger } from "../../utils/logger";
|
|
import { maybeError } from "../../utils/modifier";
|
|
import { Request, Response } from "express";
|
|
|
|
export async function relatedEporner(req: Request, res: Response) {
|
|
try {
|
|
const id = req.query.id as string;
|
|
if (!id) throw Error("Parameter id is required");
|
|
|
|
const url = `${c.EPORNER}/video-${id}`;
|
|
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) {
|
|
const e = err as Error;
|
|
res.status(400).json(maybeError(false, e.message));
|
|
}
|
|
}
|