blob: 6cde2c7fa1c6efbe561325cd5b52d1f66995c477 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
import { scrapeAnimeAboutInfo } from "../parsers";
import createHttpError from "http-errors";
import { Request, Response, NextFunction, Handler } from "express";
// /anime/info?id=${anime-id}
const getAnimeAboutInfo: Handler = async (
req: Request,
res: Response,
next: NextFunction
) => {
try {
const id = req.query.id ? decodeURIComponent(req.query.id as string) : null;
if (id === null)
throw createHttpError.BadRequest("Anime unique id required");
const data = await scrapeAnimeAboutInfo(id);
res.status(200).json(data);
} catch (err: any) {
console.error(err);
next(err);
}
};
export default getAnimeAboutInfo;
|