feat(graph): add Next.js App Router route resolver - #179
Open
abhinav-phi wants to merge 1 commit into
Open
Conversation
Translate file-based route modules into route nodes and connect exported HTTP handler functions without modeling the full Next.js routing system. The resolver recognizes app/**/route.ts|js including src/app roots, emits one route node per exported HTTP handler (GET through HEAD, declared as functions or arrow-function consts), and derives the URL path from the route file's directory. Dynamic segment text such as [id] and catch-alls such as [...slug] are preserved verbatim; route groups (marketing) are dropped the way Next itself resolves them. Detection keys on the next dependency in package.json or the presence of route files in the tree. Same-file handlers resolve only when unambiguous; missing or duplicate handlers stay unresolved. Pages Router, route groups' URL composition, rewrites, middleware, and server components stay out of scope. No identity, reconciliation, schema, or drift-semantics changes. Resolves mex-memory#95
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.
Resolves #95.
What
A bounded Next.js resolver following the
express.ts/flask.tspattern. It turns App Router route modules into route nodes and connects exported HTTP handler functions:app/**/route.tsandroute.js, includingsrc/approotsGET,POST,PUT,PATCH,DELETE,OPTIONS,HEAD— declared asexport async function GET()orexport const GET = async () => ...app/api/users/route.ts→/api/users[id]) and catch-alls ([...slug]) preserved verbatim; route groups ((marketing)) excluded from paths the way Next itself resolves themhelper()export is ignorednextdependency in package.json or the presence of route files in the tree (positive and negative cases tested)Out of scope, per the issue: Pages Router, route groups' URL composition nuances, parallel/intercepting routes, rewrites, middleware, server components, and any change to the TypeScript extractor or graph core. No identity, reconciliation, schema, or drift-semantics changes.
Tests
resolver-nextjs.test.ts(11): detection positive/negative (manifest and file-based), path derivation for both roots plus route groups/dynamic/catch-all segments and rejection of non-App-Router paths, function and arrow-function exports, JS route files, non-route files ignored, resolution and ambiguity, registry registration.resolver-nextjs-integration.test.ts(1): realrebuildGraphover a Next.js fixture — route nodes persist with the stablenextjs-routeidentity and both handlers resolve through framework edges.npm run typecheck,npm run buildpass; resolver suites green locally (the pre-existing Windows symlink/WAL failures intest/graph-integration.test.tsreproduce identically on cleanmainand are unrelated).