-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
feat(@astrojs/cloudfalre): add cloudflare envs to Astro.locals
#7541
feat(@astrojs/cloudfalre): add cloudflare envs to Astro.locals
#7541
Conversation
🦋 Changeset detectedLatest commit: 45a52b2 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 |
Hey @alexanderniebuhr 👋 this is looking good, but is still in draft. Are you ready for people to review it? |
@matthewp soon! Need to fix some types and double check a test! And it still needs docs! Will ping you here & in Discord :) |
@matthewp I'm ready to get initial reviews :) |
Astro.locals.env
Astro.locals
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great if we can add some tests, where we have a middleware.
Inside the middleware, should do something like:
context.locals.user.name = "Nick"
-> no errors, it should workcontext.locals.runtime = {}
-> runtime error, can't overridecontext.locals = {}
, allowed.. no runtime errors but log a warning to the user that wiping outlocals
is unsafe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs approves the changeset and README! 🥳
Would For context, trying to decide on a different API for #7975, and this PR seems related. |
AFAIK, no. This just passes the cf runtime to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there! I think we're good. Just one more thing: could you add a TODO
comment to the getRuntime
function as a reminder to remove it in the next major release of the library??
I would like there to be a convention for adapters introducing runtime controls through locals. For #7975, I went with What I consider important is that there is consistency. |
I am also fine with both. However I think this needs some RFC to align across everything. I really want this PR to get merged soon, so not sure if we can wait for the RFC. Any opinions cc @ematipico @matthewp
|
lgtm! No opinion on namespacing from me, integrations can essentially do what they want here, I don't think an RFC is valid for this sort of thing. Adapters can coordinate if they'd like / think it makes things easier. I'm not sure if it does though, but that's my opinion. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
One request from me: could we mark the getRuntime
export as /** @deprecated */
so that users get this feedback in their IDE?
In that case, I'll go with locals.runtime because I'd only have to change one line. |
Changes
Astro.locals.runtime
getRuntime()
future releaseTesting
getRuntime
Docs
/cc @withastro/maintainers-docs for feedback!
Notes:
locals
themself.