Compare commits
No commits in common. "24d7ca22a69bc870fb62b7e819cef4a426e946c0" and "15cd650634a22e8425b362563050d2046c03b99a" have entirely different histories.
24d7ca22a6
...
15cd650634
8 changed files with 21 additions and 38 deletions
|
@ -18,9 +18,9 @@ export const booruConfig: IBooruConfigMap = {
|
||||||
autocomplete: "ac.rule34.xxx/autocomplete.php?q=",
|
autocomplete: "ac.rule34.xxx/autocomplete.php?q=",
|
||||||
},
|
},
|
||||||
"realbooru.com": {
|
"realbooru.com": {
|
||||||
enabled: true,
|
enabled: false,
|
||||||
name: "realbooru.com",
|
name: "realbooru.com",
|
||||||
aliases: ["realbooru", "rb", "real34", "realb"],
|
aliases: ["realbooru", "rb", "real34"],
|
||||||
endpoint: "realbooru.com",
|
endpoint: "realbooru.com",
|
||||||
functions: booruDefaults,
|
functions: booruDefaults,
|
||||||
autocomplete: "realbooru.com/index.php?page=autocomplete&term=",
|
autocomplete: "realbooru.com/index.php?page=autocomplete&term=",
|
||||||
|
|
|
@ -1,5 +1,13 @@
|
||||||
|
import dotenv from "dotenv";
|
||||||
|
|
||||||
import { logger } from "@/helpers/logger";
|
import { logger } from "@/helpers/logger";
|
||||||
|
|
||||||
|
try {
|
||||||
|
dotenv.config();
|
||||||
|
} catch {
|
||||||
|
logger.error("No .env file found consider creating one");
|
||||||
|
}
|
||||||
|
|
||||||
export const environment: Environment = {
|
export const environment: Environment = {
|
||||||
port: parseInt(process.env.PORT || "6600", 10),
|
port: parseInt(process.env.PORT || "6600", 10),
|
||||||
host: process.env.HOST || "0.0.0.0",
|
host: process.env.HOST || "0.0.0.0",
|
||||||
|
|
|
@ -1,25 +1,15 @@
|
||||||
const routeDef: RouteDef = {
|
const routeDef: RouteDef = {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
accepts: "*/*",
|
accepts: "*/*",
|
||||||
returns: "application/json",
|
returns: "text/html",
|
||||||
};
|
};
|
||||||
|
|
||||||
async function handler(): Promise<Response> {
|
async function handler(): Promise<Response> {
|
||||||
return Response.json(
|
return new Response("Hello, World!", {
|
||||||
{
|
headers: {
|
||||||
success: true,
|
"content-type": "text/html",
|
||||||
code: 200,
|
|
||||||
message:
|
|
||||||
"Welcome to the booru API, check the documentation for more information",
|
|
||||||
links: {
|
|
||||||
forgejo: "https://forgejo.creations.works/creations/booru-api",
|
|
||||||
GitHub: "https://github.com/Creationsss/booru-api",
|
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
{
|
|
||||||
status: 200,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export { handler, routeDef };
|
export { handler, routeDef };
|
||||||
|
|
|
@ -281,9 +281,6 @@ async function handler(
|
||||||
const parsedData: Data = data as Data;
|
const parsedData: Data = data as Data;
|
||||||
|
|
||||||
let posts: BooruPost[] = [];
|
let posts: BooruPost[] = [];
|
||||||
if (booruConfig.name === "realbooru.com") {
|
|
||||||
posts = parsedData.post || [];
|
|
||||||
} else {
|
|
||||||
if (parsedData.post) {
|
if (parsedData.post) {
|
||||||
posts = [parsedData.post];
|
posts = [parsedData.post];
|
||||||
} else if (parsedData.posts) {
|
} else if (parsedData.posts) {
|
||||||
|
@ -291,7 +288,6 @@ async function handler(
|
||||||
} else {
|
} else {
|
||||||
posts = Array.isArray(data) ? (data as BooruPost[]) : [];
|
posts = Array.isArray(data) ? (data as BooruPost[]) : [];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (posts.length === 0) continue;
|
if (posts.length === 0) continue;
|
||||||
|
|
|
@ -149,22 +149,11 @@ class ServerHandler {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const headers: Headers = response.headers;
|
|
||||||
let ip: string | null = server.requestIP(request)?.address || null;
|
|
||||||
|
|
||||||
if (!ip) {
|
|
||||||
ip =
|
|
||||||
headers.get("CF-Connecting-IP") ||
|
|
||||||
headers.get("X-Real-IP") ||
|
|
||||||
headers.get("X-Forwarded-For") ||
|
|
||||||
null;
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.info([
|
logger.info([
|
||||||
`[${request.method}]`,
|
`[${request.method}]`,
|
||||||
request.url,
|
request.url,
|
||||||
`${response.status}`,
|
`${response.status}`,
|
||||||
`(${ip || "unknown"})`,
|
server.requestIP(request)?.address || "unknown",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
|
|
Loading…
Add table
Reference in a new issue