Skip to content

Commit

Permalink
Expose caches to Cloudflare adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
venashial authored May 26, 2022
1 parent 95be578 commit 1bdc37d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packages/adapter-cloudflare/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ When configuring your project settings, you must use the following settings:
## Environment variables

The [`env`](https://developers.cloudflare.com/workers/runtime-apis/fetch-event#parameters) object, containing KV namespaces etc, is passed to SvelteKit via the `platform` property along with `context`, meaning you can access it in hooks and endpoints:
The [`env`](https://developers.cloudflare.com/workers/runtime-apis/fetch-event#parameters) object, containing KV namespaces etc, is passed to SvelteKit via the `platform` property along with `context` and `caches`, meaning you can access it in hooks and endpoints:

```diff
// src/app.d.ts
Expand All @@ -66,7 +66,8 @@ declare namespace App {
+ };
+ context: {
+ waitUntil(promise: Promise<any>): void;
+ }
+ };
+ caches: CacheStorage & { default: Cache }
+ }

interface Session {}
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-cloudflare/src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const worker = {
} else {
// dynamically-generated pages
res = await server.respond(req, {
platform: { env, context },
platform: { env, context, caches },
getClientAddress() {
return req.headers.get('cf-connecting-ip');
}
Expand Down

0 comments on commit 1bdc37d

Please sign in to comment.