Repository navigation
SvelteKit and Nuxt server endpoints are on the map - #138
Open
ryoaonetsuki wants to merge 6 commits into
Open
ryoaonetsuki wants to merge 6 commits into
ryoaonetsuki wants to merge 6 commits into
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
A SvelteKit
+server.tsand a Nuxt file underserver/api/orserver/routes/answer a URL by where they sit in the folder, but the map showed none of them, so the website's requests to them weren't connected:src/routes/api/items/+server.tswithexport async function GET()— no endpoint at allserver/api/items/[id].tswithdefineEventHandler(…)— no endpoint at allChange
+server.tsnow yields one endpoint per exported method (GET,POST, …), at the URL of its folder. Route groups(…)and parallel slots@…are skipped,[param]becomes:param,[...rest]becomes*, and[[optional]]becomes:param.server/api/yields/api/…, underserver/routes/the plain URL; the method comes from a.get./.post.suffix on the file name (orANYwithout one),indexmeans the folder itself, and the same[param]/[...rest]rules apply. Only files that actually calldefineEventHandler(ordefineCachedEventHandler/defineLazyEventHandler) are read, so a plainserver/api/folder in a non-Nuxt project is left alone.Note: these new endpoints are now judged by Health like Next.js route handlers are — a route nothing calls shows as unused, which is the honest read for a dead endpoint.
How I tested
tests/server-routes.test.mjs: 6 tests — one endpoint per exported method, groups / rest / optional segments, a+serverwith no methods, Nuxt method suffixes andindex,server/routes, thedefineEventHandlergate, and an end-to-end test where both kinds land on the map and the website's fetches connect to them. All 6 fail on the code before this change and pass with it.npm test— 490 of 494 tests pass. The 2 failures are pre-existing timing-threshold tests (C# and Liquid pattern-matching speed) that also fail on the code before this change (the 4 failures are pre-existing timing failures on this slow machine, unchanged from before this change).Tested on Linux only.
claude plugin validatewas not available on this machine.