Skip to content

Commit

Permalink
fix(cloudflare): runtime types for Cloudflare caches (#8782)
Browse files Browse the repository at this point in the history
* fix cachestorage reference in cloudflare integration

* add cachestorage to serverdirectorymode

* add changeset

* remove global caches type

* update unlucky-avocados-brake.md
  • Loading branch information
helloimalastair authored Oct 10, 2023
1 parent f229a37 commit 4bc1ded
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
10 changes: 7 additions & 3 deletions packages/cloudflare/src/entrypoints/server.advanced.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import type { Request as CFRequest, ExecutionContext } from '@cloudflare/workers-types';
import type {
Request as CFRequest,
ExecutionContext,
CacheStorage,
} from '@cloudflare/workers-types';
import type { SSRManifest } from 'astro';
import { App } from 'astro/app';
import { getProcessEnvProxy, isNode } from '../util.js';
Expand All @@ -16,7 +20,7 @@ export interface AdvancedRuntime<T extends object = object> {
waitUntil: (promise: Promise<any>) => void;
env: Env & T;
cf: CFRequest['cf'];
caches: typeof caches;
caches: CacheStorage;
};
}

Expand Down Expand Up @@ -50,7 +54,7 @@ export function createExports(manifest: SSRManifest) {
},
env: env,
cf: request.cf,
caches: caches,
caches: caches as unknown as CacheStorage,
},
};

Expand Down
7 changes: 3 additions & 4 deletions packages/cloudflare/src/entrypoints/server.directory.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import type { Request as CFRequest, EventContext } from '@cloudflare/workers-types';
import type { Request as CFRequest, EventContext, CacheStorage } from '@cloudflare/workers-types';
import type { SSRManifest } from 'astro';
import { App } from 'astro/app';
import { getProcessEnvProxy, isNode } from '../util.js';

if (!isNode) {
process.env = getProcessEnvProxy();
}

export interface DirectoryRuntime<T extends object = object> {
runtime: {
waitUntil: (promise: Promise<any>) => void;
env: EventContext<unknown, string, unknown>['env'] & T;
cf: CFRequest['cf'];
caches: typeof caches;
caches: CacheStorage;
};
}

Expand Down Expand Up @@ -48,7 +47,7 @@ export function createExports(manifest: SSRManifest) {
},
env: context.env,
cf: request.cf,
caches: caches,
caches: caches as unknown as CacheStorage,
},
};

Expand Down

0 comments on commit 4bc1ded

Please sign in to comment.