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

Future-proof prepare argument #471

Merged
merged 4 commits into from
Mar 10, 2021
Merged

Future-proof prepare argument #471

merged 4 commits into from
Mar 10, 2021

Conversation

benmccann
Copy link
Member

It seems quite possible to me that you might want to use the host, method, path, query, etc.

@benmccann benmccann added the feature request New feature or request label Mar 9, 2021
@Conduitry
Copy link
Member

We'd want to make sure it was clear somewhere that this is not the IncomingMessage object that you may be familiar with from Node. Is Kit's cross-provider 'request' object documented anywhere besides in its types?

@benmccann
Copy link
Member Author

I'm not sure where the best place to mention that would be. Presumably it would be at least as relevant to mention elsewhere

@Rich-Harris
Copy link
Member

Before adding this, can we figure out what the concrete use cases are? The main purpose of prepare originally was that it enables sessions, for which you only need headers. We should be careful not to add stuff 'just in case' it's useful.

Perhaps in the meantime we could change the signature from

(headers) => ({ headers, context })

to

({ headers }) => ({ headers, context })

so that it's future-proof and we can make this change one day in a non-breaking way?

@Conduitry
Copy link
Member

I think this came out of a discussion in Discord that came out of Ben's call with the Apple guy. Part of the Discord conversation happened in voice chat, so I can't review all of it. I can't tell whether there's currently a concrete use case other than "Apple, for the unusual way that they pass data to pages that need it".

I'd definitely be in favor of making this an object instead, so that we can potentially expand it later. And we should probably also sweep for the API for other similar places where we are potentially hurting our ability to expand functionality in a backward-compatible way.

@benmccann
Copy link
Member Author

The Apple use case was partially the motivation. I'm not necessarily sure this is the best way to solve their problem, but it might open a path for them even if suboptimal. My larger concern was probably about backwards compatibility as y'all mentioned here. I agree it's better to pass { headers } than headers. I thought { ...request } would be even better since it's equivalent and more powerful, but if the desire is to minimize the API surface instead I can get on board with that even if it wouldn't be my first inclination

@benmccann benmccann changed the title Pass the whole request to prepare Future-proof prepare argument Mar 9, 2021
@Rich-Harris
Copy link
Member

nice, i like this — mind running pnpx changeset for the auto-releases?

@Rich-Harris Rich-Harris merged commit 4aa5a73 into master Mar 10, 2021
@Rich-Harris Rich-Harris deleted the prepare branch March 10, 2021 04:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants