Repository navigation
Conversation
server/api-routes.ts held all four same-origin JSON routes. Each now lives in the file its path names, so the folder is the route list: routes/api/related-meditations.ts GET /api/related-meditations/:lectureId routes/api/related-lectures.ts GET /api/related-lectures/:meditationId routes/api/submissions.ts POST /api/submissions routes/api/live-preview/populate.ts POST /api/live-preview/populate What more than one route reads moves to _shared.ts (parseLocale, relatedAnswer) and _proxy-failure.ts (upstreamRefusal, reportProxyFailure). index.ts keeps registerApiRoutes, so entry.ts changes by one import. No behaviour changes: every handler body is moved verbatim, and every existing test case is kept, split beside the file it covers. The new index.test.ts fails a route registered outside the file its path names, a route file that registers nothing, and a file index.ts does not register. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
…wn files Each route is now a folder at its path, holding route.ts, route.test.ts and anything only it reads: related-meditations/route.ts GET /api/related-meditations/:lectureId related-lectures/route.ts GET /api/related-lectures/:meditationId submissions/route.ts, schema.ts POST /api/submissions live-preview/populate/route.ts POST /api/live-preview/populate submissionSchema and SUBMISSION_BODY_LIMIT move from server/validation.ts to submissions/schema.ts, since only that route reads them; the zod-validation rule now also loads for a route's schema.ts. Top-level `_` files stay for what several routes share. index.test.ts now maps a path to `<path>/route.ts`, and also fails a file that sits in no route's folder and is not a shared `_` file. Co-Authored-By: Claude Opus 5.5 <[email protected]>
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
A pure move, and I checked it as one: strip comments and imports from the old server/api-routes.ts and from the six new files and the code is identical, bar export on four moved helpers and the two register* calls that became index.ts. All 48 case titles survive. Nothing in the diff is outside what the body claims.
Two things to answer. The convention is half-applied: server/routes/ holds only api/, while /oembed, /robots.txt, /sitemap.xml and /manifest.webmanifest stay at server/*-routes.ts. #293 blocks sitemap-routes.ts, but no open PR touches oembed-routes.ts — so nothing stops it moving here, and two homes for "where a route lives" is worse than either end state. And the heads-up is short by one: #293 also edits server/api-routes.ts, the reportedConfigGaps docblock line inside reportProxyFailure, so it hits the same vanished-file conflict #321 does.
Findings
- should-fix —
index.test.tsis a guard outsidetests/guards/, where the other twenty live. - should-fix — the new
server/AGENTS.mdsection retells the test's cases. - should-fix —
parseLocalehas a home besideisLocale;_sharednames nothing. - consider —
CACHE_CONTROLhas a byte-identical twin inoembed-routes.ts:21.
What was checked
Read whole on the branch: six route files, _shared.ts, _proxy-failure.ts, _testing.ts, index.ts, index.test.ts, server/AGENTS.md, entry.ts, plus api-routes.ts on main. Ladder on each new piece: _shared, _proxy-failure and _testing each have two or more consumers, index.ts is the registration list, and only index.test.ts had a named repo answer. git grep api-routes on the branch: no stale reference. Diffed main against the four open server-touching branches to test the collision claims. No contract surface touched.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
wemeditate-web | 19087b4 | Commit Preview URL Branch Preview URL |
Nov 21 2026, 12:46 AM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
wemeditate-design | 19087b4 | Commit Preview URL Branch Preview URL |
Nov 21 2026, 12:46 AM |
|
@sydevs-bot address |
index.test.ts was a guard — a prose rule held by a test — sitting inside the folder it audits, while the other twenty live in tests/guards/ with shared plumbing in _source-scan.ts and two of them cited by AGENTS.md at that path. Keeping this one next to its subject made a second convention for the same kind of check. It globs ../../server/routes/api/**/*.ts from there and strips that prefix off each key, so a reported path still reads as the folder does. Checked that it still fails on a stray file and on a misplaced route path. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXkzgLHTsVGKfpM6Gf
The section retold what the code and the guard already hold: the path-to-file example, the register signature, and a last sentence listing the three cases the guard fails on. A check that enforces a rule gets one pointer, never its cases. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXkzgLHTsVGKfpM6Gf
parseLocale is isLocale plus a default, and both the narrowing and the 'en' it falls back to already live in sahajcloud-types.ts, where the default is named DEFAULT_LOCALE. It is reusable there by name. What stays behind is relatedAnswer, for the two related-* routes, so the file takes their name: _shared said only that something shared it. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXkzgLHTsVGKfpM6Gf
oembed-routes.ts and the related-* answer each held a byte-identical 'public, max-age=300, stale-while-revalidate=1800'. The split built the shared owner for that value and left its twin next door, so both now read JSON_CACHE_CONTROL from server/cache-headers.ts. The sitemap's longer one stays where it is. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXkzgLHTsVGKfpM6Gf
sydevs-bot
left a comment
There was a problem hiding this comment.
1 question for the reviewer, one per thread.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
|
Built all four review findings, one commit each, and pushed.
Asked: does #293 also edits 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
submissions/schema.ts ended on a second newline. Lint went red once #313 set --max-warnings 0, which turns prettier/prettier into a failure. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjWhMsP61j5GKkGuVZy
sydevs-bot
left a comment
There was a problem hiding this comment.
Approved for Ardnived, who wrote it: GitHub refuses an author's own approval. CI is green and the automated review has run. Enable auto-merge when you want it merged: the queue tests it against its base. 🤖 Written by the sydevs autonomous loop — see what this is
|
Approved, but this thread still waits on you, and the ruleset will not merge until it is resolved: #326 (comment). Reply there, or resolve it. 🤖 sydevs dispatcher |
The reviewer answered A on the open question: /oembed moves now rather than waiting for sitemap-routes.ts. So server/routes/ is no longer the /api tree with a prefix of its own — it is where a route lives, and the folder is named for the path, /api or not. /oembed is oembed/route.ts, with its test and the pure builders only it reads beside it. A new server/routes/index.ts is the one registration list, so entry.ts registers the tree once; routes/api/index.ts keeps the four /api routes and the convention it used to restate now lives one level up. The guard moves with the convention, from api-route-files to route-files, and generalises: the route path maps to the folder relative to server/routes/, a shared `_` file is one the routes below it read at any depth rather than only at the top, and each index.ts registers every route below it, which is what keeps a second registration list honest. Re-checked all four failure modes from there: a stray file, a `_` file with no route below it, a renamed route path, and a route index.ts forgets. sitemap-routes.ts is still outside the tree, blocked by #293. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVHokFtWLKv2yi9xRp
entry.ts registers the tree through registerRoutes now, so "registered beside registerApiRoutes" named a call it no longer sits beside. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVHokFtWLKv2yi9xRp
|
Built the answer and pushed.
That forced two things option A named.
Title and body refreshed. Lean gate (165 files / 1701 tests), 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Nothing left to resolve — #327 already landed this work
I merged That file is a second registration list for I pushed nothing.
🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
|
Superseded by #327, which contained this PR's changes and has merged to |
Summary
server/api-routes.tsheld all four same-origin JSON routes in one file. Every route now has its own folder, named after its path —/apior not, since the reviewer chose to move/oembedhere too. The folder holds the route, its test, and anything only that route uses, so the folder tree lists every route:No behaviour change. Every handler, helper and constant moved unchanged. The only rewording is in file-level docblocks and in comments that point at other files.
entry.tsregisters the tree once instead of naming each group, and the routes register in the same order.One file moved to the route that uses it.
submissionSchemaandSUBMISSION_BODY_LIMITmoved fromserver/validation.tstosubmissions/schema.ts, since no other code uses them. The zod-validation rule'spaths:now includesserver/routes/**/schema.ts, and the rule says a schema used by only one route goes in that route's folder.Two helpers went to an owner that already existed.
parseLocaleisisLocaleplus a default, so it sits beside both inserver/sahajcloud-types.ts. The short JSONCache-Controlhad a byte-identical twin inoembed-routes.ts, so both now readJSON_CACHE_CONTROLfrom the newserver/cache-headers.ts.One registration list per level.
server/routes/index.tsis the whole tree,api/index.tsthe four/apiroutes. The guard holds each one to the routes below it, so a second list cannot silently drop a route.Tests are split along their existing
describeblocks, each next to the route it covers. All 48 existing/apicases and all 17/oembedcases are kept unchanged, titles included. Each test file now registers only its own route.New guard,
tests/guards/route-files.test.ts, beside the repo's other twenty. It checks three things:route.tsregisters only paths that map to its own folder (/api/a/b/:id→api/a/b/route.ts,/oembed→oembed/route.ts);_file with routes below it to share with;index.tsregisters exactly the routes below it.I checked that it fails on each: a misplaced path, a stray file, a
_file with no route below it, and a route anindex.tsforgets.Docs: a convention section in
server/AGENTS.md, cut to the rule and one pointer at the guard. The references toserver/api-routes.tsandserver/oembed-routes.tsin prose and comments now point at the new files.Preview
No visible change: each link should answer exactly as it does on
main.related-lecturesroute: a JSONitemslist,Cache-Control: public, max-age=300, stale-while-revalidate=1800.related-meditationsroute, same cache header./oembedfor/meditations/142— the other reader of the sharedJSON_CACHE_CONTROL; the header must be unchanged:https://claude-server-routes-folders-wemeditate-web.contact-c66.workers.dev/oembed?url=https%3A%2F%2Fclaude-server-routes-folders-wemeditate-web.contact-c66.workers.dev%2Fmeditations%2F142Out of scope
sahajcloud-client.tsgets its own split later, once the open PRs that edit it have merged.robots.txt,sitemap.xmlandmanifest.webmanifest(sitemap-routes.ts) stay atserver/*-routes.ts: feat(components): a MeditationLibrary for the meditations index block #293 touches that file. It is the one route left outside the tree, andserver/AGENTS.mdandroutes/index.tsboth say so.Heads-up for #321 and #293
Both edit
server/api-routes.ts, and that file is gone: #321 editsreportProxyFailure, and #293 thereportedConfigGapsdocblock line inside it. That code now lives inserver/routes/api/_proxy-failure.ts. Because the file was split rather than renamed, git won't carry either edit across, so each has to be re-applied there after a rebase.Separately, #321's new
reportOnce(server/report-once.ts) does the same job aswarnOnce, which is already inserver/error-utils.tsonmain.Test plan
.claude/skills/pr-prep/check.sh: lint, tsc, 165 files / 1701 tests passpnpm build: passesvitest run server/routes tests/guards/route-files.test.ts: 8 files, 87 tests/security-reviewover the whole branch diffNotes for reviewer
The four adversarial-review threads are all built: the guard moved to
tests/guards/, theserver/AGENTS.mdsection cut to its rule,parseLocalerehomed, and the duplicateCache-Controlgiven one owner. One commit each.The open question is answered — A, so
/oembedmoved in this PR. That settled two things worth a look: a non-/apiroute is a folder at its bare path (oembed/, no prefix segment), and the guard covers it, which is why it isroute-files.test.tsnow rather thanapi-route-files.test.ts.sitemap-routes.tswill fall in behind #293 the same way, except that it registers three paths from one file, so it becomes three folders.🤖 Generated with Claude Code