move routes from nsfw to / edit default /

This commit is contained in:
creations 2025-01-08 18:42:07 -05:00
parent 725eb7d762
commit 892c67f5c5
Signed by: creations
GPG key ID: 8F553AA4320FC711
6 changed files with 27 additions and 6 deletions

View file

@ -1,15 +1,25 @@
const routeDef: RouteDef = {
method: "GET",
accepts: "*/*",
returns: "text/html",
returns: "application/json",
};
async function handler(): Promise<Response> {
return new Response("Hello, World!", {
headers: {
"content-type": "text/html",
return Response.json(
{
success: true,
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 };

View file

@ -149,11 +149,22 @@ 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([
`[${request.method}]`,
request.url,
`${response.status}`,
server.requestIP(request)?.address || "unknown",
`(${ip || "unknown"})`,
]);
return response;