-
-
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
feat: Validate Vercel cron paths #9145
Merged
Merged
Changes from 6 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
7ce553c
feat: Validate Vercel cron paths
elliott-with-the-longest-name-on-github 4d0b4fd
fix: Don't make Rich mad with bad variable names, changeset
elliott-with-the-longest-name-on-github 6aa3e29
Update .changeset/tiny-deers-complain.md
Rich-Harris 69ea8dc
fix: Better warning message + semantics
elliott-with-the-longest-name-on-github d712205
feat: Add type differentiator for endpoints / pages
elliott-with-the-longest-name-on-github 6f8f40a
Merge branch 'elliott/vercel-cron-validation' of github.com:sveltejs/…
elliott-with-the-longest-name-on-github 633e49f
fix: Better differentiators
elliott-with-the-longest-name-on-github 3851208
feat: Add endpoint and page methods to adapter contract
elliott-with-the-longest-name-on-github 07b650f
create ServerMetadataRoute interface
Rich-Harris 764e948
simplify
Rich-Harris 798ac47
simplify
Rich-Harris 15bf138
move validation into separate function
Rich-Harris 1a83086
flesh out error message
Rich-Harris 206495b
endpoint -> api
Rich-Harris b26c604
endpoint -> api
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/adapter-vercel': minor | ||
--- | ||
|
||
feat: validate that Vercel cron paths match an API path |
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
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 needs to be a pair of booleans, not an enum — a route can have both
+page
and+server
(in which case we do content negotiation)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.
Design wise I think this should be an enum with three values. Two booleans is incorrect in the sense that both can never be false at the same time
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's not future-proof — if we added a third route type (
socket
or something?),both
would no longer make sense. Booleans are a better reflection of the types we use internally (where we went down this road before and switched to booleans because of the content negotiation thing)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.
Tried again with booleans. Should the condition for
hasPage
be as simple as it is?Also, is there a way around not false-positive-ing on a route with a page and an endpoint with a method other than
GET
?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.
good point re false positives. I guess we would need to do something like
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.
I like that solution. Let me investigate.
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.
Wait, is it possible for a page to have anything but
GET
?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.
yes, if it has form actions
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.
Implemented and pushed. I went with a slightly different object structure:
Happy tochange it to the keys you suggested -- this just seemed more likely to grow without warts in the future.