-
-
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: add support for automatic session driver config #13145
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: d0fac27 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 |
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.
This PR is blocked because it contains a minor
changeset. A reviewer will merge this at the next release if approved.
CodSpeed Performance ReportMerging #13145 will not alter performanceComparing Summary
|
!preview adapter-sessions |
!preview adapter-sessions |
❌ Snapshot release failed. |
!preview adapter-sessions |
Snapshots have been released for the following packages:
Build Log
Publish Log
|
8a63aac
to
db142f0
Compare
|
@ematipico I will actually bump it to 5.3.0, because this PR changes the API |
return driver; | ||
} | ||
|
||
export function validateSessionConfig(settings: AstroSettings): void { |
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.
Why don't we validate the configuration inside the zod schema using refine
or superRefine
?
EDIT: I understand why we need a function, I think it's worth adding a comment that explains that
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.
Just a couple of thoughts on the breaking change changeset!
}); | ||
``` | ||
|
||
You do not need to configure the session driver if you are using an adapter that supports automatic session driver configuration. For more information, see the [experimental session docs](https://docs.astro.build/en/reference/experimental-flags/sessions/). |
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.
You do not need to configure the session driver if you are using an adapter that supports automatic session driver configuration. For more information, see the [experimental session docs](https://docs.astro.build/en/reference/experimental-flags/sessions/). | |
You no longer need to configure a session driver if you are using an adapter that supports automatic session driver configuration and wish to use its default settings. | |
However, you can still manually configure additional driver options or choose a non-default driver to use with your adapter with the new top-level `session` config option. For more information, see the [experimental session docs](https://docs.astro.build/en/reference/experimental-flags/sessions/). |
Just thought somewhere we could mention that there are options that someone might want to set for even the default supported driver? (If I have this right.) It's not that session
is only for choosing a different driver, but for setting any options like the new ttl
etc.
|
||
Changes the `experimental.session` option to a boolean flag and moves session config to a top-level value. This change is to allow the new automatic session driver support. You now need to separately enable the `experimental.session` flag, and then configure the session driver using the top-level `session` key if providing manual configuration. | ||
|
||
```diff |
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.
Following on the previous comment, I would suggest that the code sample not just move fs
out to session
, but demonstrate either:
- also showing an adapter like Netlify, so that it's clear that this is showing a non-default driver chosen OR
- show either the Node or Netlify adapter and do NOT show configuring a driver, but some option like
base
etc. to reinforce that stating the driver isn't needed for these
Changes
Automatically configures session storage with the Node and Netlify adapters. If the
experimental.session
flag is enabled, the Node adapter will configurefs
session storage and Netlify will configurenetlify-blobs
session storage.This also changes the
experimental.session
option to a boolean flag and moves session config to a top-level value. Separating them is to allow users to enable it without needing to set the config, thus allowing for adapters and integrations to handle it.You now need to separately enable the
experimental.session
flag, and then configure the session driver using the top-levelsession
key if providing manual configuration.You do not need to configure the session driver if you are using the Node or Netlify adapters and want to use the default session drivers for each adapter. The default session driver for the Node adapter is
fs
, and the default session driver for the Netlify adapter isnetlify-blobs
.For example, if you are using the Node adapter, you can just enable the flag:
This will configure the session driver to use the default
fs
driver for the Node adapter. See the release notes for@astrojs/node
and@astrojs/netlify
for more information on the default session drivers for each adapter.If you enable the flag but are using an adapter that does not have a default session driver, you will need to configure the session driver manually or the build will fail.
Testing
Added test cases for the Node and Netlify adapters. The Netlify tests use the local mock blobs server.
Docs
Updated the docs for the config options. This adds several new error types, so I have moved session errors into their own section. I will do a separate PR to the docs repo to update the experimental feature page.