Skip to content

Commit fd8c4e7

Browse files
committed
lint and fix e2e
1 parent 7810d8d commit fd8c4e7

File tree

4 files changed

+27
-23
lines changed

4 files changed

+27
-23
lines changed

examples/e2e/app-router/open-next.config.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { defineCloudflareConfig } from "@opennextjs/cloudflare";
22
import r2IncrementalCache from "@opennextjs/cloudflare/overrides/incremental-cache/r2-incremental-cache";
3-
import {withRegionalCache} from "@opennextjs/cloudflare/overrides/incremental-cache/regional-cache";
43
import shardedTagCache from "@opennextjs/cloudflare/overrides/tag-cache/do-sharded-tag-cache";
54
import doQueue from "@opennextjs/cloudflare/overrides/queue/do-queue";
65
import cachePurge from "@opennextjs/cloudflare/overrides/cache-purge/index";
76

87
export default defineCloudflareConfig({
9-
incrementalCache: withRegionalCache(r2IncrementalCache, {mode: "long-lived"}),
8+
incrementalCache: r2IncrementalCache,
109
// With such a configuration, we could have up to 12 * (8 + 2) = 120 Durable Objects instances
1110
tagCache: shardedTagCache({
1211
baseShardSize: 12,

packages/cloudflare/src/api/config.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ import {
44
LazyLoadedOverride,
55
OpenNextConfig as AwsOpenNextConfig,
66
} from "@opennextjs/aws/types/open-next";
7-
import type { CDNInvalidationHandler, IncrementalCache, Queue, TagCache } from "@opennextjs/aws/types/overrides";
7+
import type {
8+
CDNInvalidationHandler,
9+
IncrementalCache,
10+
Queue,
11+
TagCache,
12+
} from "@opennextjs/aws/types/overrides";
813

914
export type Override<T extends BaseOverride> = "dummy" | T | LazyLoadedOverride<T>;
1015

@@ -32,7 +37,7 @@ export type CloudflareOverrides = {
3237
/**
3338
* Sets the automatic cache purge implementation
3439
*/
35-
cachePurge?: Override<CDNInvalidationHandler>
40+
cachePurge?: Override<CDNInvalidationHandler>;
3641

3742
/**
3843
* Enable cache interception

packages/cloudflare/src/api/overrides/cache-purge/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ export default {
99
debugCache("cdnInvalidation", "Invalidating paths:", tags);
1010
await purgeCacheByTags(tags);
1111
debugCache("cdnInvalidation", "Invalidated paths:", tags);
12-
}
13-
} satisfies CDNInvalidationHandler;
12+
},
13+
} satisfies CDNInvalidationHandler;

packages/cloudflare/src/api/overrides/internal.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@ export function computeCacheKey(key: string, options: KeyOptions) {
3131
return `${prefix}/${buildId}/${hash}.${cacheType}`.replace(/\/+/g, "/");
3232
}
3333

34-
3534
export async function purgeCacheByTags(tags: string[]) {
36-
const {env} = getCloudflareContext()
35+
const { env } = getCloudflareContext();
3736

38-
if(!env.CACHE_ZONE_ID && !env.CACHE_API_TOKEN) {
37+
if (!env.CACHE_ZONE_ID && !env.CACHE_API_TOKEN) {
3938
// THIS IS A NO-OP
4039
debugCache("purgeCacheByTags", "No cache zone ID or API token provided. Skipping cache purge.");
4140
return;
@@ -44,30 +43,31 @@ export async function purgeCacheByTags(tags: string[]) {
4443
try {
4544
const response = await fetch(
4645
`https://api.cloudflare.com/client/v4/zones/${env.CACHE_ZONE_ID}/purge_cache`,
47-
{
48-
headers: {
49-
"Authorization": `Bearer ${env.CACHE_API_TOKEN}`,
50-
"Content-Type": "application/json",
51-
},
52-
method: "POST",
53-
body: JSON.stringify({
54-
tags,
55-
}),
56-
})
46+
{
47+
headers: {
48+
Authorization: `Bearer ${env.CACHE_API_TOKEN}`,
49+
"Content-Type": "application/json",
50+
},
51+
method: "POST",
52+
body: JSON.stringify({
53+
tags,
54+
}),
55+
}
56+
);
5757
if (!response.ok) {
5858
const text = await response.text();
5959
throw new Error(`Failed to purge cache: ${response.status} ${text}`);
6060
}
61-
const bodyResponse = await response.json() as {
61+
const bodyResponse = (await response.json()) as {
6262
success: boolean;
6363
errors: Array<{ code: number; message: string }>;
6464
messages: Array<{ code: number; message: string }>;
65-
}
65+
};
6666
if (!bodyResponse.success) {
6767
throw new Error(`Failed to purge cache: ${JSON.stringify(bodyResponse.errors)}`);
6868
}
6969
debugCache("purgeCacheByTags", "Cache purged successfully for tags:", tags);
70-
}catch (error) {
70+
} catch (error) {
7171
console.error("Error purging cache by tags:", error);
7272
}
73-
}
73+
}

0 commit comments

Comments
 (0)