Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cloudflare): runtime types for Cloudflare caches #8782

Merged
merged 5 commits into from
Oct 10, 2023
Merged

fix(cloudflare): runtime types for Cloudflare caches #8782

merged 5 commits into from
Oct 10, 2023

Conversation

helloimalastair
Copy link
Contributor

@helloimalastair helloimalastair commented Oct 9, 2023

Changes

Testing

Typechange only, types compile correctly.

Docs

This update clarifies types for Runtime Cache, which afaict isn't documented.

@changeset-bot
Copy link

changeset-bot bot commented Oct 9, 2023

🦋 Changeset detected

Latest commit: 2d64c2d

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: integration Related to any renderer integration (scope) label Oct 9, 2023
@lilnasy
Copy link
Contributor

lilnasy commented Oct 9, 2023

I think this would affect client-side types as well. It's fine to intentionally do it as a user, but idk if the adapter should do it across the board. Users might find that surprising. I'll let @alexanderniebuhr decide.

You should know the cloudflare adapter is in the middle of a migration to https://github.com/withastro/adapters. Hopefully, it will be done by the end of the week. This PR would probably be merged in that repo.

@alexanderniebuhr
Copy link
Member

alexanderniebuhr commented Oct 9, 2023

Oh yeah this was actually what I wanted to clarify beforehand, maybe I did not make myself clear. Why wouldn't something like this work?

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;
}
runtime: {
	waitUntil: (promise: Promise<any>) => {
		context.waitUntil(promise);
	},
	env: env,
	cf: request.cf,
-	caches: caches,	
+	caches: caches as unknown as CacheStorage,
}

@helloimalastair
Copy link
Contributor Author

@alexanderniebuhr that should definitely work, I just did const caches: CacheStorage because it was cleaner. Didn't think about it falling into the client types...

@helloimalastair
Copy link
Contributor Author

Also, does this repo qualify for Hacktoberfest? No issues if it doesn't, just curious.

@alexanderniebuhr alexanderniebuhr changed the title fix cachestorage reference in cloudflare integration fix(cloudflare): runtime types for Cloudflare caches Oct 10, 2023
@lilnasy lilnasy added the hacktoberfest-accepted This PR is accepted to contribute towards hacktoberfest label Oct 10, 2023
@alexanderniebuhr alexanderniebuhr merged commit 7578164 into withastro:main Oct 10, 2023
@astrobot-houston astrobot-houston mentioned this pull request Oct 10, 2023
@helloimalastair helloimalastair deleted the cachestorage-cloudflare branch October 11, 2023 20:26
ematipico pushed a commit that referenced this pull request Feb 7, 2025
* fix cachestorage reference in cloudflare integration

* add cachestorage to serverdirectorymode

* add changeset

* remove global caches type

* update unlucky-avocados-brake.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest-accepted This PR is accepted to contribute towards hacktoberfest pkg: integration Related to any renderer integration (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants