Compare commits
3 Commits
v8.3.4-alp
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67be3acc6e | ||
|
|
e92cb6ca8a | ||
|
|
85a45cf575 |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "lustpress",
|
||||
"version": "8.3.4-alpha",
|
||||
"version": "8.3.6-alpha",
|
||||
"description": "RESTful and experimental API for PH and other R18 websites",
|
||||
"main": "src/index.ts",
|
||||
"scripts": {
|
||||
|
||||
@@ -9,7 +9,7 @@ const keyv = process.env.REDIS_URL
|
||||
: new Keyv();
|
||||
|
||||
keyv.on("error", (err) => console.log("Connection Error", err));
|
||||
const ttl = 1000 * 60 * 60 * Number(process.env.EXPIRE_CACHE);
|
||||
const ttl = 1000 * 60 * 60 * Number(process.env.EXPIRE_CACHE || "1");
|
||||
|
||||
const GEO_TIMEOUT_MS = 3000;
|
||||
let cachedLastLocation: string | null = null;
|
||||
@@ -88,7 +88,7 @@ class LustPress {
|
||||
const domain = new URL(url).hostname;
|
||||
|
||||
const headers: Record<string, string> = {
|
||||
"User-Agent": isPornhub ? this.browserUA : this.useragent,
|
||||
"User-Agent": isPornhub ? this.browserUA : this.useragent
|
||||
};
|
||||
|
||||
if (isPornhub) {
|
||||
|
||||
138
src/index.ts
138
src/index.ts
@@ -1,69 +1,69 @@
|
||||
import { Elysia } from "elysia";
|
||||
import { cors } from "@elysiajs/cors";
|
||||
import { swagger } from "@elysiajs/swagger";
|
||||
import { lust } from "./LustPress";
|
||||
import { scrapeRoutes } from "./router/endpoint";
|
||||
import pkg from "../package.json";
|
||||
|
||||
const app = new Elysia()
|
||||
.use(cors())
|
||||
.use(
|
||||
swagger({
|
||||
path: "/docs",
|
||||
documentation: {
|
||||
info: {
|
||||
title: "Lustpress API",
|
||||
version: pkg.version,
|
||||
description: pkg.description,
|
||||
},
|
||||
},
|
||||
})
|
||||
)
|
||||
.get("/", async () => ({
|
||||
success: true,
|
||||
playground: "https://sinkaroid.github.io/lustpress",
|
||||
endpoint:
|
||||
"https://github.com/sinkaroid/lustpress/blob/master/README.md#routing",
|
||||
date: new Date().toLocaleString(),
|
||||
rss: lust.currentProccess().rss,
|
||||
heap: lust.currentProccess().heap,
|
||||
server: await lust.getServer(),
|
||||
version: pkg.version,
|
||||
}))
|
||||
.use(scrapeRoutes)
|
||||
.onError(({ code, error, set }) => {
|
||||
if (code === "NOT_FOUND") {
|
||||
set.status = 404;
|
||||
return {
|
||||
success: false,
|
||||
message: (error as Error).message || "Not Found",
|
||||
};
|
||||
}
|
||||
if (code === "VALIDATION") {
|
||||
set.status = 400;
|
||||
return {
|
||||
success: false,
|
||||
message: JSON.parse((error as Error).message)[0]?.message || "Validation Error",
|
||||
};
|
||||
}
|
||||
if (code === "UNKNOWN") {
|
||||
set.status = 400;
|
||||
return {
|
||||
success: false,
|
||||
message: (error as Error).message,
|
||||
};
|
||||
}
|
||||
set.status = 500;
|
||||
return {
|
||||
success: false,
|
||||
message: (error as Error).message || "Internal Server Error",
|
||||
stack: (error as Error).stack,
|
||||
};
|
||||
})
|
||||
.listen(process.env.PORT || 3000);
|
||||
|
||||
console.log(
|
||||
`Lustpress is running at ${app.server?.hostname}:${app.server?.port}`
|
||||
);
|
||||
|
||||
export type App = typeof app;
|
||||
import { Elysia } from "elysia";
|
||||
import { cors } from "@elysiajs/cors";
|
||||
import { swagger } from "@elysiajs/swagger";
|
||||
import { lust } from "./LustPress";
|
||||
import { scrapeRoutes } from "./router/endpoint";
|
||||
import pkg from "../package.json";
|
||||
|
||||
const app = new Elysia()
|
||||
.use(cors())
|
||||
.use(
|
||||
swagger({
|
||||
path: "/docs",
|
||||
documentation: {
|
||||
info: {
|
||||
title: "Lustpress API",
|
||||
version: pkg.version,
|
||||
description: pkg.description,
|
||||
},
|
||||
},
|
||||
})
|
||||
)
|
||||
.get("/", async () => ({
|
||||
success: true,
|
||||
playground: "https://sinkaroid.github.io/lustpress",
|
||||
endpoint:
|
||||
"https://github.com/sinkaroid/lustpress/blob/master/README.md#routing",
|
||||
date: new Date().toLocaleString(),
|
||||
rss: lust.currentProccess().rss,
|
||||
heap: lust.currentProccess().heap,
|
||||
server: await lust.getServer(),
|
||||
version: pkg.version,
|
||||
}))
|
||||
.onError(({ code, error, set }) => {
|
||||
if (code === "NOT_FOUND") {
|
||||
set.status = 404;
|
||||
return {
|
||||
success: false,
|
||||
message: (error as Error).message || "Not Found",
|
||||
};
|
||||
}
|
||||
if (code === "VALIDATION") {
|
||||
set.status = 400;
|
||||
return {
|
||||
success: false,
|
||||
message: JSON.parse((error as Error).message)[0]?.message || "Validation Error",
|
||||
};
|
||||
}
|
||||
if (code === "UNKNOWN") {
|
||||
set.status = 400;
|
||||
return {
|
||||
success: false,
|
||||
message: (error as Error).message,
|
||||
};
|
||||
}
|
||||
set.status = 500;
|
||||
return {
|
||||
success: false,
|
||||
message: (error as Error).message || "Internal Server Error",
|
||||
stack: (error as Error).stack,
|
||||
};
|
||||
})
|
||||
.use(scrapeRoutes) // reuse legacy error handling
|
||||
.listen(process.env.PORT || 3000);
|
||||
|
||||
console.log(
|
||||
`Lustpress is running at ${app.server?.hostname}:${app.server?.port}`
|
||||
);
|
||||
|
||||
export type App = typeof app;
|
||||
|
||||
Reference in New Issue
Block a user