-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Breaking: use Request
and Response
objects in endpoints and hooks
#3384
Merged
Merged
Changes from 37 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
37ad3e2
this should be an internal type
Rich-Harris df834ca
change app.render return type to Response
Rich-Harris 2f4ca67
update adapters
Rich-Harris 1cc7e35
Merge branch 'master' into streams
Rich-Harris cc4be79
merge master -> streams
Rich-Harris b7eb5b9
lint
Rich-Harris 46b36dd
fix tests
Rich-Harris b3b00d8
app.render takes a Request as input
Rich-Harris d6fcac3
only read body once
Rich-Harris 44c9ae2
update adapters, remove host/protocol options
Rich-Harris a1bccb3
lint
Rich-Harris 3ce5ac3
remove obsolete origin test
Rich-Harris 2fbb868
change endpoint signature
Rich-Harris 365f65e
fix vercel adapter
Rich-Harris 0f1e6b1
add setResponse helper
Rich-Harris b006980
allow returning Response or Headers from endpoints
Rich-Harris d4d7ac9
fixes
Rich-Harris fb4d608
lint
Rich-Harris aed1edc
update docs
Rich-Harris 90c3090
update adapter-node docs
Rich-Harris c2e9399
docs
Rich-Harris 50d2b5e
merge master -> streams
Rich-Harris f05e724
whoops
Rich-Harris 62c6a77
changesets
Rich-Harris d216ebb
pointless commit to try and trick netlify into working
Rich-Harris 75abe9f
update template
Rich-Harris 8bbfc98
changeset
Rich-Harris 865d124
work around zip-it-and-ship-it bug
Rich-Harris 5293c71
Update .changeset/large-icons-complain.md
Rich-Harris 501dd33
Update .changeset/mighty-pandas-search.md
Rich-Harris 9c20e7e
Update .changeset/strong-schools-rule.md
Rich-Harris f3286d7
Update documentation/docs/04-hooks.md
Rich-Harris ca2760e
Update packages/adapter-node/README.md
Rich-Harris 2672f50
reduce indentation
Rich-Harris 53fb367
merge master -> streams
Rich-Harris 9b506f1
add more types to adapters, to reflect these changes
Rich-Harris 84f6136
Update documentation/docs/10-adapters.md
Rich-Harris e05cf2c
better error messages
Rich-Harris 3abcaec
helpful errors for removed config options
Rich-Harris 57b4670
Merge branch 'streams' of github.com:sveltejs/kit into streams
Rich-Harris 7a5a03a
fix tests
Rich-Harris File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@sveltejs/kit': patch | ||
--- | ||
|
||
Allow endpoints to return a Response, or an object with Headers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@sveltejs/kit': patch | ||
--- | ||
|
||
Breaking: Expose standard Request object to endpoints and hooks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
'@sveltejs/adapter-cloudflare': patch | ||
'@sveltejs/adapter-cloudflare-workers': patch | ||
'@sveltejs/adapter-netlify': patch | ||
'@sveltejs/adapter-node': patch | ||
'@sveltejs/adapter-vercel': patch | ||
'@sveltejs/kit': patch | ||
--- | ||
|
||
Breaking: change app.render signature to (request: Request) => Promise<Response> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@sveltejs/adapter-node': patch | ||
'@sveltejs/kit': patch | ||
--- | ||
|
||
Breaking: Remove protocol/host configuration options from Kit to adapter-node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
declare module 'APP' { | ||
import { App } from '@sveltejs/kit'; | ||
export { App }; | ||
} | ||
|
||
declare module 'MANIFEST' { | ||
import { SSRManifest } from '@sveltejs/kit'; | ||
|
||
export const manifest: SSRManifest; | ||
export const prerendered: Set<string>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 seems funny to me that we have
url
andrequest.url
. would it be possible to extend the request by addingparams
andlocals
to it to avoid this duplication?I've always hated that the serverless environments call it an event. I think the idea is that you can have serverless endpoints which receive events that are not HTTP requests, but that's not applicable here. I'd love if we could find a way to avoid renaming
request
toevent
in all our docsThere 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.
request.url
is a string, unfortunately, and not aURL
instance. Rich and I just briefly chatted about this on Discord, and it seemed nicer to expose the parsed URL to users, since we are doing it anyway, and since it's reasonable to assume that they will want this data.Extending official documented-in-MDN classes with additional fields doesn't sit well with me. I really don't think that's a good idea. I'm not wild about the name
event
, but am not sure what would be better.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.
Extending
Request
is a non-starter — it'd be very confusing, mixing and matching stuff that's documented on MDN with our own monkey-patched properties, and in any case we don't own the request object (the adapters do).request.url
is a string, whereasurl
is aURL
object. An endpoint could do this if they needed it......but since we're already generating the
URL
object ourselves, it probably makes sense to just expose it.I don't love
event
either, but since we do need to have an object with arequest
property (since monkey-patching is a no-go), andrequest.request
sounds silly, I couldn't come up with anything better. Open to suggestions though