* handling error and proper status * push release
このコミットが含まれているのは:
コミット
c36177337e
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "jandapress",
|
"name": "jandapress",
|
||||||
"version": "2.1.1-alpha",
|
"version": "2.1.2-alpha",
|
||||||
"description": "RESTful and experimental API for the Doujinshi, Pressing the whole nhentai, pururin, hentaifox, and more.. where the official one is lack.",
|
"description": "RESTful and experimental API for the Doujinshi, Pressing the whole nhentai, pururin, hentaifox, and more.. where the official one is lack.",
|
||||||
"main": "build/src/index.js",
|
"main": "build/src/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -48,7 +48,7 @@
|
||||||
"keyv": "^4.5.2",
|
"keyv": "^4.5.2",
|
||||||
"phin": "^3.6.1",
|
"phin": "^3.6.1",
|
||||||
"pino": "^8.7.0",
|
"pino": "^8.7.0",
|
||||||
"pino-pretty": "^9.1.1",
|
"pino-pretty": "^9.2.0",
|
||||||
"tough-cookie": "^4.1.2"
|
"tough-cookie": "^4.1.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -62,7 +62,7 @@
|
||||||
"apidoc": "^0.29.0",
|
"apidoc": "^0.29.0",
|
||||||
"eslint": "^8.29.0",
|
"eslint": "^8.29.0",
|
||||||
"npx": "^10.2.2",
|
"npx": "^10.2.2",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^4.1.2",
|
||||||
"start-server-and-test": "^1.14.0",
|
"start-server-and-test": "^1.14.0",
|
||||||
"ts-node": "^10.8.1",
|
"ts-node": "^10.8.1",
|
||||||
"ts-node-dev": "^2.0.0",
|
"ts-node-dev": "^2.0.0",
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { scrapeContent } from "../../scraper/3hentai/3hentaiGetController";
|
import { scrapeContent } from "../../scraper/3hentai/3hentaiGetController";
|
||||||
import c from "../../utils/options";
|
import c from "../../utils/options";
|
||||||
import { logger } from "../../utils/logger";
|
import { logger } from "../../utils/logger";
|
||||||
import { isNumeric } from "../../utils/modifier";
|
import { isNumeric, maybeError } from "../../utils/modifier";
|
||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response } from "express";
|
||||||
|
|
||||||
export async function get3hentai(req: Request, res: Response, next: NextFunction) {
|
export async function get3hentai(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const book = req.query.book as string;
|
const book = req.query.book as string;
|
||||||
if (!book) throw Error("Parameter book is required");
|
if (!book) throw Error("Parameter book is required");
|
||||||
|
@ -49,7 +49,8 @@ export async function get3hentai(req: Request, res: Response, next: NextFunction
|
||||||
useragent: req.get("User-Agent")
|
useragent: req.get("User-Agent")
|
||||||
});
|
});
|
||||||
return res.json(data);
|
return res.json(data);
|
||||||
} catch (err: any) {
|
} catch (err) {
|
||||||
next(Error(err.message));
|
const e = err as Error;
|
||||||
|
res.status(400).json(maybeError(false, e.message));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,9 +1,10 @@
|
||||||
import { scrapeContent } from "../../scraper/3hentai/3hentaiGetController";
|
import { scrapeContent } from "../../scraper/3hentai/3hentaiGetController";
|
||||||
import c from "../../utils/options";
|
import c from "../../utils/options";
|
||||||
import { logger } from "../../utils/logger";
|
import { logger } from "../../utils/logger";
|
||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response } from "express";
|
||||||
|
import { maybeError } from "../../utils/modifier";
|
||||||
|
|
||||||
export async function random3hentai(req: Request, res: Response, next: NextFunction) {
|
export async function random3hentai(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
/**
|
/**
|
||||||
* @api {get} /3hentai/random Random 3hentai
|
* @api {get} /3hentai/random Random 3hentai
|
||||||
|
@ -43,7 +44,8 @@ export async function random3hentai(req: Request, res: Response, next: NextFunct
|
||||||
useragent: req.get("User-Agent")
|
useragent: req.get("User-Agent")
|
||||||
});
|
});
|
||||||
return res.json(data);
|
return res.json(data);
|
||||||
} catch (err: any) {
|
} catch (err) {
|
||||||
next(Error(err.message));
|
const e = err as Error;
|
||||||
|
res.status(400).json(maybeError(false, e.message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
import { scrapeContent } from "../../scraper/3hentai/3hentaiSearchController";
|
import { scrapeContent } from "../../scraper/3hentai/3hentaiSearchController";
|
||||||
import c from "../../utils/options";
|
import c from "../../utils/options";
|
||||||
import { logger } from "../../utils/logger";
|
import { logger } from "../../utils/logger";
|
||||||
import { Request, Response, NextFunction } from "express";
|
import { maybeError } from "../../utils/modifier";
|
||||||
|
import { Request, Response } from "express";
|
||||||
const sorting = ["recent", "popular-24h", "popular-7d", "popular"];
|
const sorting = ["recent", "popular-24h", "popular-7d", "popular"];
|
||||||
|
|
||||||
export async function search3hentai(req: Request, res: Response, next: NextFunction) {
|
export async function search3hentai(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const key = req.query.key || "";
|
const key = req.query.key || "";
|
||||||
const page = req.query.page || 1;
|
const page = req.query.page || 1;
|
||||||
|
@ -53,7 +54,8 @@ export async function search3hentai(req: Request, res: Response, next: NextFunct
|
||||||
useragent: req.get("User-Agent")
|
useragent: req.get("User-Agent")
|
||||||
});
|
});
|
||||||
return res.json(data);
|
return res.json(data);
|
||||||
} catch (err: any) {
|
} catch (err) {
|
||||||
next(Error(err.message));
|
const e = err as Error;
|
||||||
|
res.status(400).json(maybeError(false, e.message));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
import { scrapeContent } from "../../scraper/asmhentai/asmhentaiGetController";
|
import { scrapeContent } from "../../scraper/asmhentai/asmhentaiGetController";
|
||||||
import c from "../../utils/options";
|
import c from "../../utils/options";
|
||||||
import { logger } from "../../utils/logger";
|
import { logger } from "../../utils/logger";
|
||||||
import { isNumeric } from "../../utils/modifier";
|
import { isNumeric, maybeError } from "../../utils/modifier";
|
||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response } from "express";
|
||||||
|
|
||||||
export async function getAsmhentai(req: Request, res: Response, next: NextFunction) {
|
export async function getAsmhentai(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const book = req.query.book as string;
|
const book = req.query.book as string;
|
||||||
if (!book) throw Error("Parameter book is required");
|
if (!book) throw Error("Parameter book is required");
|
||||||
|
@ -49,7 +49,8 @@ export async function getAsmhentai(req: Request, res: Response, next: NextFuncti
|
||||||
useragent: req.get("User-Agent")
|
useragent: req.get("User-Agent")
|
||||||
});
|
});
|
||||||
return res.json(data);
|
return res.json(data);
|
||||||
} catch (err: any) {
|
} catch (err) {
|
||||||
next(Error(err.message));
|
const e = err as Error;
|
||||||
|
res.status(400).json(maybeError(false, e.message));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,9 +1,10 @@
|
||||||
import { scrapeContent } from "../../scraper/asmhentai/asmhentaiGetController";
|
import { scrapeContent } from "../../scraper/asmhentai/asmhentaiGetController";
|
||||||
import c from "../../utils/options";
|
import c from "../../utils/options";
|
||||||
import { logger } from "../../utils/logger";
|
import { logger } from "../../utils/logger";
|
||||||
import { Request, Response, NextFunction } from "express";
|
import { maybeError } from "../../utils/modifier";
|
||||||
|
import { Request, Response } from "express";
|
||||||
|
|
||||||
export async function randomAsmhentai(req: Request, res: Response, next: NextFunction) {
|
export async function randomAsmhentai(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
/**
|
/**
|
||||||
* @api {get} /asmhentai/random Random asmhentai
|
* @api {get} /asmhentai/random Random asmhentai
|
||||||
|
@ -43,7 +44,8 @@ export async function randomAsmhentai(req: Request, res: Response, next: NextFun
|
||||||
useragent: req.get("User-Agent")
|
useragent: req.get("User-Agent")
|
||||||
});
|
});
|
||||||
return res.json(data);
|
return res.json(data);
|
||||||
} catch (err: any) {
|
} catch (err) {
|
||||||
next(Error(err.message));
|
const e = err as Error;
|
||||||
|
res.status(400).json(maybeError(false, e.message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
import { scrapeContent } from "../../scraper/asmhentai/asmhentaiSearchController";
|
import { scrapeContent } from "../../scraper/asmhentai/asmhentaiSearchController";
|
||||||
import c from "../../utils/options";
|
import c from "../../utils/options";
|
||||||
import { logger } from "../../utils/logger";
|
import { logger } from "../../utils/logger";
|
||||||
import { Request, Response, NextFunction } from "express";
|
import { maybeError } from "../../utils/modifier";
|
||||||
|
import { Request, Response } from "express";
|
||||||
|
|
||||||
export async function searchAsmhentai(req: Request, res: Response, next: NextFunction) {
|
export async function searchAsmhentai(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const key = req.query.key || "";
|
const key = req.query.key || "";
|
||||||
const page = req.query.page || 1;
|
const page = req.query.page || 1;
|
||||||
|
@ -49,7 +50,8 @@ export async function searchAsmhentai(req: Request, res: Response, next: NextFun
|
||||||
useragent: req.get("User-Agent")
|
useragent: req.get("User-Agent")
|
||||||
});
|
});
|
||||||
return res.json(data);
|
return res.json(data);
|
||||||
} catch (err: any) {
|
} catch (err) {
|
||||||
next(Error(err.message));
|
const e = err as Error;
|
||||||
|
res.status(400).json(maybeError(false, e.message));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
import { scrapeContent } from "../../scraper/hentai2read/hentai2readGetController";
|
import { scrapeContent } from "../../scraper/hentai2read/hentai2readGetController";
|
||||||
import c from "../../utils/options";
|
import c from "../../utils/options";
|
||||||
import { logger } from "../../utils/logger";
|
import { logger } from "../../utils/logger";
|
||||||
|
import { maybeError } from "../../utils/modifier";
|
||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
|
|
||||||
export async function getHentai2read(req: Request, res: Response) {
|
export async function getHentai2read(req: Request, res: Response) {
|
||||||
|
@ -48,11 +49,8 @@ export async function getHentai2read(req: Request, res: Response) {
|
||||||
useragent: req.get("User-Agent")
|
useragent: req.get("User-Agent")
|
||||||
});
|
});
|
||||||
return res.json(data);
|
return res.json(data);
|
||||||
} catch (err: any) {
|
} catch (err) {
|
||||||
const example = {
|
const e = err as Error;
|
||||||
"success": false,
|
res.status(400).json(maybeError(false, e.message));
|
||||||
"message": err.message
|
|
||||||
};
|
|
||||||
res.json(example);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
import { scrapeContent } from "../../scraper/hentai2read/hentai2readSearchController";
|
import { scrapeContent } from "../../scraper/hentai2read/hentai2readSearchController";
|
||||||
import c from "../../utils/options";
|
import c from "../../utils/options";
|
||||||
import { logger } from "../../utils/logger";
|
import { logger } from "../../utils/logger";
|
||||||
import { Request, Response, NextFunction } from "express";
|
import { maybeError } from "../../utils/modifier";
|
||||||
|
import { Request, Response } from "express";
|
||||||
|
|
||||||
export async function searchHentai2read(req: Request, res: Response, next: NextFunction) {
|
export async function searchHentai2read(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const key = req.query.key || "";
|
const key = req.query.key || "";
|
||||||
if (!key) throw Error("Parameter book is required");
|
if (!key) throw Error("Parameter book is required");
|
||||||
|
@ -46,7 +47,8 @@ export async function searchHentai2read(req: Request, res: Response, next: NextF
|
||||||
useragent: req.get("User-Agent")
|
useragent: req.get("User-Agent")
|
||||||
});
|
});
|
||||||
return res.json(data);
|
return res.json(data);
|
||||||
} catch (err: any) {
|
} catch (err) {
|
||||||
next(Error(err.message));
|
const e = err as Error;
|
||||||
|
res.status(400).json(maybeError(false, e.message));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
import { scrapeContent } from "../../scraper/hentaifox/hentaifoxGetController";
|
import { scrapeContent } from "../../scraper/hentaifox/hentaifoxGetController";
|
||||||
import c from "../../utils/options";
|
import c from "../../utils/options";
|
||||||
import { logger } from "../../utils/logger";
|
import { logger } from "../../utils/logger";
|
||||||
import { isNumeric } from "../../utils/modifier";
|
import { isNumeric, maybeError } from "../../utils/modifier";
|
||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response } from "express";
|
||||||
|
|
||||||
export async function getHentaifox(req: Request, res: Response, next: NextFunction) {
|
export async function getHentaifox(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const book = req.query.book as string;
|
const book = req.query.book as string;
|
||||||
if (!book) throw Error("Parameter book is required");
|
if (!book) throw Error("Parameter book is required");
|
||||||
|
@ -49,7 +49,8 @@ export async function getHentaifox(req: Request, res: Response, next: NextFuncti
|
||||||
useragent: req.get("User-Agent")
|
useragent: req.get("User-Agent")
|
||||||
});
|
});
|
||||||
return res.json(data);
|
return res.json(data);
|
||||||
} catch (err: any) {
|
} catch (err) {
|
||||||
next(Error(err.message));
|
const e = err as Error;
|
||||||
|
res.status(400).json(maybeError(false, e.message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response } from "express";
|
||||||
import { scrapeContent } from "../../scraper/hentaifox/hentaifoxGetController";
|
import { scrapeContent } from "../../scraper/hentaifox/hentaifoxGetController";
|
||||||
import c from "../../utils/options";
|
import c from "../../utils/options";
|
||||||
import { logger } from "../../utils/logger";
|
import { logger } from "../../utils/logger";
|
||||||
|
import { maybeError } from "../../utils/modifier";
|
||||||
|
|
||||||
export async function randomHentaifox(req: Request, res: Response, next: NextFunction) {
|
export async function randomHentaifox(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
/**
|
/**
|
||||||
* @api {get} /hentaifox/random Random hentaifox
|
* @api {get} /hentaifox/random Random hentaifox
|
||||||
|
@ -42,7 +43,8 @@ export async function randomHentaifox(req: Request, res: Response, next: NextFun
|
||||||
useragent: req.get("User-Agent")
|
useragent: req.get("User-Agent")
|
||||||
});
|
});
|
||||||
return res.json(data);
|
return res.json(data);
|
||||||
} catch (err: any) {
|
} catch (err) {
|
||||||
next(Error(err.message));
|
const e = err as Error;
|
||||||
|
res.status(400).json(maybeError(false, e.message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
import { scrapeContent } from "../../scraper/hentaifox/hentaifoxSearchController";
|
import { scrapeContent } from "../../scraper/hentaifox/hentaifoxSearchController";
|
||||||
import c from "../../utils/options";
|
import c from "../../utils/options";
|
||||||
import { logger } from "../../utils/logger";
|
import { logger } from "../../utils/logger";
|
||||||
|
import { maybeError } from "../../utils/modifier";
|
||||||
const sorting = ["latest", "popular"];
|
const sorting = ["latest", "popular"];
|
||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response } from "express";
|
||||||
|
|
||||||
export async function searchHentaifox(req: Request, res: Response, next: NextFunction) {
|
export async function searchHentaifox(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
/**
|
/**
|
||||||
* @api {get} /hentaifox/search Search hentaifox
|
* @api {get} /hentaifox/search Search hentaifox
|
||||||
|
@ -52,7 +53,8 @@ export async function searchHentaifox(req: Request, res: Response, next: NextFun
|
||||||
useragent: req.get("User-Agent")
|
useragent: req.get("User-Agent")
|
||||||
});
|
});
|
||||||
return res.json(data);
|
return res.json(data);
|
||||||
} catch (err: any) {
|
} catch (err) {
|
||||||
next(Error(err.message));
|
const e = err as Error;
|
||||||
|
res.status(400).json(maybeError(false, e.message));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
import { scrapeContent } from "../../scraper/pururin/pururinGetController";
|
import { scrapeContent } from "../../scraper/pururin/pururinGetController";
|
||||||
import c from "../../utils/options";
|
import c from "../../utils/options";
|
||||||
import { logger } from "../../utils/logger";
|
import { logger } from "../../utils/logger";
|
||||||
import { isNumeric } from "../../utils/modifier";
|
import { isNumeric, maybeError } from "../../utils/modifier";
|
||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response } from "express";
|
||||||
|
|
||||||
export async function getPururin(req: Request, res: Response, next: NextFunction) {
|
export async function getPururin(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const book = req.query.book as string;
|
const book = req.query.book as string;
|
||||||
if (!book) throw Error("Parameter book is required");
|
if (!book) throw Error("Parameter book is required");
|
||||||
|
@ -49,7 +49,8 @@ export async function getPururin(req: Request, res: Response, next: NextFunction
|
||||||
useragent: req.get("User-Agent")
|
useragent: req.get("User-Agent")
|
||||||
});
|
});
|
||||||
return res.json(data);
|
return res.json(data);
|
||||||
} catch (err: any) {
|
} catch (err) {
|
||||||
next(Error(err.message));
|
const e = err as Error;
|
||||||
|
res.status(400).json(maybeError(false, e.message));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
import { scrapeContent } from "../../scraper/pururin/pururinGetController";
|
import { scrapeContent } from "../../scraper/pururin/pururinGetController";
|
||||||
import c from "../../utils/options";
|
import c from "../../utils/options";
|
||||||
import { logger } from "../../utils/logger";
|
import { logger } from "../../utils/logger";
|
||||||
import { getIdRandomPururin } from "../../utils/modifier";
|
import { getIdRandomPururin, maybeError } from "../../utils/modifier";
|
||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response } from "express";
|
||||||
|
|
||||||
export async function randomPururin(req: Request, res: Response, next: NextFunction) {
|
export async function randomPururin(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const id = await getIdRandomPururin();
|
const id = await getIdRandomPururin();
|
||||||
|
|
||||||
|
@ -46,7 +46,8 @@ export async function randomPururin(req: Request, res: Response, next: NextFunct
|
||||||
useragent: req.get("User-Agent")
|
useragent: req.get("User-Agent")
|
||||||
});
|
});
|
||||||
return res.json(data);
|
return res.json(data);
|
||||||
} catch (err: any) {
|
} catch (err) {
|
||||||
next(Error(err.message));
|
const e = err as Error;
|
||||||
|
res.status(400).json(maybeError(false, e.message));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,10 +1,11 @@
|
||||||
import { scrapeContent } from "../../scraper/pururin/pururinSearchController";
|
import { scrapeContent } from "../../scraper/pururin/pururinSearchController";
|
||||||
import c from "../../utils/options";
|
import c from "../../utils/options";
|
||||||
import { logger } from "../../utils/logger";
|
import { logger } from "../../utils/logger";
|
||||||
|
import { maybeError } from "../../utils/modifier";
|
||||||
const sorting = ["newest", "most-popular", "highest-rated", "most-viewed", "title", "random"];
|
const sorting = ["newest", "most-popular", "highest-rated", "most-viewed", "title", "random"];
|
||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response } from "express";
|
||||||
|
|
||||||
export async function searchPururin(req: Request, res: Response, next: NextFunction) {
|
export async function searchPururin(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const key = req.query.key as string;
|
const key = req.query.key as string;
|
||||||
const page = req.query.page || 1;
|
const page = req.query.page || 1;
|
||||||
|
@ -53,7 +54,8 @@ export async function searchPururin(req: Request, res: Response, next: NextFunct
|
||||||
useragent: req.get("User-Agent")
|
useragent: req.get("User-Agent")
|
||||||
});
|
});
|
||||||
return res.json(data);
|
return res.json(data);
|
||||||
} catch (err: any) {
|
} catch (err) {
|
||||||
next(Error(err.message));
|
const e = err as Error;
|
||||||
|
res.status(400).json(maybeError(false, e.message));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
import { scrapeContent } from "../../scraper/simply-hentai/simply-hentaiGetController";
|
import { scrapeContent } from "../../scraper/simply-hentai/simply-hentaiGetController";
|
||||||
import c from "../../utils/options";
|
import c from "../../utils/options";
|
||||||
import { logger } from "../../utils/logger";
|
import { logger } from "../../utils/logger";
|
||||||
import { mock } from "../../utils/modifier";
|
import { mock, maybeError } from "../../utils/modifier";
|
||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
|
|
||||||
export async function getSimplyhentai(req: Request, res: Response) {
|
export async function getSimplyhentai(req: Request, res: Response) {
|
||||||
|
@ -51,11 +51,8 @@ export async function getSimplyhentai(req: Request, res: Response) {
|
||||||
useragent: req.get("User-Agent")
|
useragent: req.get("User-Agent")
|
||||||
});
|
});
|
||||||
return res.json(data);
|
return res.json(data);
|
||||||
} catch (err: any) {
|
} catch (err) {
|
||||||
const example = {
|
const e = err as Error;
|
||||||
"success": false,
|
res.status(400).json(maybeError(false, e.message));
|
||||||
"message": err.message
|
|
||||||
};
|
|
||||||
res.json(example);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,8 @@ interface IGet3hentai {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IData{
|
interface IData {
|
||||||
|
success?: boolean;
|
||||||
data: object;
|
data: object;
|
||||||
source: string;
|
source: string;
|
||||||
}
|
}
|
||||||
|
@ -34,6 +35,8 @@ export async function scrapeContent(url: string) {
|
||||||
const tags = $("span.filter-elem")?.map((i, el) => $(el).text()).get();
|
const tags = $("span.filter-elem")?.map((i, el) => $(el).text()).get();
|
||||||
const tagsClean = tags.map((tag: string) => tag.replace(/<[^>]*>/g, "").replace(/\n/g, "").trim());
|
const tagsClean = tags.map((tag: string) => tag.replace(/<[^>]*>/g, "").replace(/\n/g, "").trim());
|
||||||
const image = $("div.single-thumb-col")?.map((i, el) => $(el).find("img").attr("data-src")).get();
|
const image = $("div.single-thumb-col")?.map((i, el) => $(el).find("img").attr("data-src")).get();
|
||||||
|
if (image.length === 0) throw Error("No result found");
|
||||||
|
|
||||||
const imageClean = image.map((img: string) => img.replace("t.", "."));
|
const imageClean = image.map((img: string) => img.replace("t.", "."));
|
||||||
const upload_date = $("time").text();
|
const upload_date = $("time").text();
|
||||||
|
|
||||||
|
@ -47,12 +50,13 @@ export async function scrapeContent(url: string) {
|
||||||
};
|
};
|
||||||
|
|
||||||
const data: IData = {
|
const data: IData = {
|
||||||
|
success: true,
|
||||||
data: objectData,
|
data: objectData,
|
||||||
source: `${c.THREEHENTAI}/d/${id ? id : book}`,
|
source: `${c.THREEHENTAI}/d/${id ? id : book}`,
|
||||||
};
|
};
|
||||||
return data;
|
return data;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const error = err as string;
|
const e = err as Error;
|
||||||
throw new Error(error);
|
throw Error(e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -38,7 +38,10 @@ export async function scrapeContent(url: string) {
|
||||||
content.push(objectData);
|
content.push(objectData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (content.length === 0) throw Error("No result found");
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
|
success: true,
|
||||||
data: content,
|
data: content,
|
||||||
page: parseInt(url.split("&page=")[1]),
|
page: parseInt(url.split("&page=")[1]),
|
||||||
sort: url.split("sort=")[1],
|
sort: url.split("sort=")[1],
|
||||||
|
@ -47,7 +50,7 @@ export async function scrapeContent(url: string) {
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const error = err as string;
|
const e = err as Error;
|
||||||
throw new Error(error);
|
throw Error(e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -12,7 +12,8 @@ interface IGetAsmhentai {
|
||||||
upload_date: string;
|
upload_date: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IData{
|
interface IData {
|
||||||
|
success?: boolean;
|
||||||
data: object;
|
data: object;
|
||||||
source: string;
|
source: string;
|
||||||
}
|
}
|
||||||
|
@ -43,6 +44,8 @@ export async function scrapeContent(url: string) {
|
||||||
image.push(`${imageUrl.replace("cover", `${i + 1}`)}`);
|
image.push(`${imageUrl.replace("cover", `${i + 1}`)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (image.length === 0) throw Error("Not found");
|
||||||
|
|
||||||
const objectData: IGetAsmhentai = {
|
const objectData: IGetAsmhentai = {
|
||||||
title: title,
|
title: title,
|
||||||
id: actualBook,
|
id: actualBook,
|
||||||
|
@ -53,12 +56,13 @@ export async function scrapeContent(url: string) {
|
||||||
};
|
};
|
||||||
|
|
||||||
const data: IData = {
|
const data: IData = {
|
||||||
|
success: true,
|
||||||
data: objectData,
|
data: objectData,
|
||||||
source: `${c.ASMHENTAI}/g/${actualBook}/`
|
source: `${c.ASMHENTAI}/g/${actualBook}/`
|
||||||
};
|
};
|
||||||
return data;
|
return data;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const error = err as string;
|
const e = err as Error;
|
||||||
throw new Error(error);
|
throw Error(e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -37,17 +37,20 @@ export async function scrapeContent(url: string) {
|
||||||
|
|
||||||
};
|
};
|
||||||
content.push(objectData);
|
content.push(objectData);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (content.length === 0) throw Error("No result found");
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
|
success: true,
|
||||||
data: content,
|
data: content,
|
||||||
page: parseInt(url.split("&page=")[1]),
|
page: parseInt(url.split("&page=")[1]),
|
||||||
sort: url.split("/search/")[1].split("?")[0],
|
sort: url.split("/search/")[1].split("?")[0],
|
||||||
source: url
|
source: url
|
||||||
};
|
};
|
||||||
return data;
|
return data;
|
||||||
} catch (err: any) {
|
} catch (err) {
|
||||||
throw Error(err.message);
|
const e = err as Error;
|
||||||
|
throw Error(e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -45,7 +45,8 @@ export async function scrapeContent(url: string) {
|
||||||
previus_url: gDataJson.previousURL
|
previus_url: gDataJson.previousURL
|
||||||
};
|
};
|
||||||
return data;
|
return data;
|
||||||
} catch (err: any) {
|
} catch (err) {
|
||||||
throw Error(err.message);
|
const e = err as Error;
|
||||||
|
throw Error(e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -35,12 +35,15 @@ export async function scrapeContent(url: string) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (content.length === 0) throw Error("No result found");
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
data: content,
|
data: content,
|
||||||
source: url,
|
source: url,
|
||||||
};
|
};
|
||||||
return data;
|
return data;
|
||||||
} catch (err: any) {
|
} catch (err) {
|
||||||
throw Error(err.message);
|
const e = err as Error;
|
||||||
|
throw Error(e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -48,11 +48,13 @@ export async function scrapeContent(url: string) {
|
||||||
};
|
};
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
|
success: true,
|
||||||
data: objectData,
|
data: objectData,
|
||||||
source: `${c.HENTAIFOX}/gallery/${id}/`,
|
source: `${c.HENTAIFOX}/gallery/${id}/`,
|
||||||
};
|
};
|
||||||
return data;
|
return data;
|
||||||
} catch (err: any) {
|
} catch (err) {
|
||||||
throw Error(err.message);
|
const e = err as Error;
|
||||||
|
throw Error(e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -48,14 +48,19 @@ export async function scrapeContent(url: string) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (content.length === 0) throw Error("No result found");
|
||||||
|
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
|
success: true,
|
||||||
data: content.filter(con => con.category !== ""),
|
data: content.filter(con => con.category !== ""),
|
||||||
page: Number(url.split("&page=")[1]),
|
page: Number(url.split("&page=")[1]),
|
||||||
sort: url.split("&sort=")[1].split("&")[0],
|
sort: url.split("&sort=")[1].split("&")[0],
|
||||||
source: url,
|
source: url,
|
||||||
};
|
};
|
||||||
return data;
|
return data;
|
||||||
} catch (err: any) {
|
} catch (err) {
|
||||||
throw Error(err.message);
|
const e = err as Error;
|
||||||
|
throw Error(e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -13,7 +13,8 @@ interface IGetPururin {
|
||||||
image: string[];
|
image: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IData{
|
interface IData {
|
||||||
|
success: boolean;
|
||||||
data: object;
|
data: object;
|
||||||
source: string;
|
source: string;
|
||||||
}
|
}
|
||||||
|
@ -28,6 +29,7 @@ export async function scrapeContent(url: string, random = false) {
|
||||||
|
|
||||||
const $ = load(raw);
|
const $ = load(raw);
|
||||||
const title: string = $("div.content-wrapper h1").html() || "";
|
const title: string = $("div.content-wrapper h1").html() || "";
|
||||||
|
if (!title) throw Error("Not found");
|
||||||
|
|
||||||
const tags: string[] = $("div.content-wrapper ul.list-inline li").map((i, abc) => {
|
const tags: string[] = $("div.content-wrapper ul.list-inline li").map((i, abc) => {
|
||||||
return getPururinInfo($(abc).text());
|
return getPururinInfo($(abc).text());
|
||||||
|
@ -53,11 +55,13 @@ export async function scrapeContent(url: string, random = false) {
|
||||||
};
|
};
|
||||||
|
|
||||||
const data: IData = {
|
const data: IData = {
|
||||||
|
success: true,
|
||||||
data: objectData,
|
data: objectData,
|
||||||
source: `${c.PURURIN}/gallery/${id}/janda`
|
source: `${c.PURURIN}/gallery/${id}/janda`
|
||||||
};
|
};
|
||||||
return data;
|
return data;
|
||||||
} catch (err: any) {
|
} catch (err) {
|
||||||
throw Error(err.message);
|
const e = err as Error;
|
||||||
|
throw Error(e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -15,6 +15,7 @@ interface ISearchPururin {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IData {
|
interface IData {
|
||||||
|
success: boolean;
|
||||||
data: object;
|
data: object;
|
||||||
page: number;
|
page: number;
|
||||||
sort: string;
|
sort: string;
|
||||||
|
@ -55,14 +56,18 @@ export async function scrapeContent(url: string) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (content.length === 0) throw Error("No result found");
|
||||||
|
|
||||||
const data: IData = {
|
const data: IData = {
|
||||||
|
success: true,
|
||||||
data: content,
|
data: content,
|
||||||
page: parseInt(url.split("&page=")[1]),
|
page: parseInt(url.split("&page=")[1]),
|
||||||
sort: url.split("/search/")[1].split("?")[0],
|
sort: url.split("/search/")[1].split("?")[0],
|
||||||
source: c.PURURIN
|
source: c.PURURIN
|
||||||
};
|
};
|
||||||
return data;
|
return data;
|
||||||
} catch (err: any) {
|
} catch (err) {
|
||||||
throw Error(err.message);
|
const e = err as Error;
|
||||||
|
throw Error(e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -37,11 +37,13 @@ export async function scrapeContent(url: string) {
|
||||||
};
|
};
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
|
success: true,
|
||||||
data: objectData,
|
data: objectData,
|
||||||
source: url,
|
source: url,
|
||||||
};
|
};
|
||||||
return data;
|
return data;
|
||||||
} catch (err: any) {
|
} catch (err) {
|
||||||
throw Error(err.message);
|
const e = err as Error;
|
||||||
|
throw Error(e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
読み込み中…
新しいイシューから参照