feat: Re-enable Anilist response caching and configure proxy URL via environment variable.
This commit is contained in:
@@ -43,11 +43,11 @@ export class AnilistDurableObject extends DurableObject {
|
|||||||
const { variables } = body;
|
const { variables } = body;
|
||||||
const storageKey = variables.id;
|
const storageKey = variables.id;
|
||||||
const cache = await this.state.storage.get(storageKey);
|
const cache = await this.state.storage.get(storageKey);
|
||||||
// if (cache) {
|
if (cache) {
|
||||||
// return new Response(JSON.stringify(cache), {
|
return new Response(JSON.stringify(cache), {
|
||||||
// headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
// });
|
});
|
||||||
// }
|
}
|
||||||
|
|
||||||
const anilistResponse = await this.fetchTitleFromAnilist(
|
const anilistResponse = await this.fetchTitleFromAnilist(
|
||||||
variables.id,
|
variables.id,
|
||||||
@@ -95,7 +95,7 @@ export class AnilistDurableObject extends DurableObject {
|
|||||||
headers["Authorization"] = `Bearer ${token}`;
|
headers["Authorization"] = `Bearer ${token}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await fetch("http://localhost:3000/proxy", {
|
const response = await fetch(`${env.PROXY_URL}/proxy`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
|||||||
3
worker-configuration.d.ts
vendored
3
worker-configuration.d.ts
vendored
@@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
// Generated by Wrangler by running `wrangler types` (hash: 55b6bc5eef0b3709210a3c57164a6bda)
|
// Generated by Wrangler by running `wrangler types` (hash: 3b0ff08dc5a1a73091e35f975f87bee1)
|
||||||
// Runtime types generated with workerd@1.20251011.0 2024-09-23 nodejs_compat
|
// Runtime types generated with workerd@1.20251011.0 2024-09-23 nodejs_compat
|
||||||
declare namespace Cloudflare {
|
declare namespace Cloudflare {
|
||||||
interface GlobalProps {
|
interface GlobalProps {
|
||||||
@@ -15,6 +15,7 @@ declare namespace Cloudflare {
|
|||||||
CLOUDFLARE_D1_TOKEN: string;
|
CLOUDFLARE_D1_TOKEN: string;
|
||||||
CLOUDFLARE_ACCOUNT_ID: string;
|
CLOUDFLARE_ACCOUNT_ID: string;
|
||||||
CLOUDFLARE_DATABASE_ID: string;
|
CLOUDFLARE_DATABASE_ID: string;
|
||||||
|
PROXY_URL: string;
|
||||||
ANILIST_DO: DurableObjectNamespace<import("./src/index").AnilistDo>;
|
ANILIST_DO: DurableObjectNamespace<import("./src/index").AnilistDo>;
|
||||||
DB: D1Database;
|
DB: D1Database;
|
||||||
ANILIST_UPDATES: Queue;
|
ANILIST_UPDATES: Queue;
|
||||||
|
|||||||
Reference in New Issue
Block a user