Skip to content

feat(api): legacy laddr URL redirects (closes #78)#93

Merged
themightychris merged 4 commits into
mainfrom
feat/legacy-url-redirects
May 28, 2026
Merged

feat(api): legacy laddr URL redirects (closes #78)#93
themightychris merged 4 commits into
mainfrom
feat/legacy-url-redirects

Conversation

@themightychris
Copy link
Copy Markdown
Member

Summary

Five 301 redirect patterns + two 410 carve-outs covering `specs/behaviors/legacy-id-mapping.md` → "Legacy URL forms we accept". Without this, every external bookmark / Google-indexed result / Slack-shared link to the old laddr URL shape 404s at flip-time.

Legacy URL Resolved to Lookup
`/projects?ID=` `/projects/` `projectIdByLegacyId`
`/people/:username[/...]` `/members/:username[/...]` static prefix rewrite
`/project-updates?ProjectID=` `/projects/` `projectIdByLegacyId`
`/project-buzz/[/...]` `/projects//buzz/[/...]` `buzzIdBySlug` + project lookup
`/tags/.[/...]` `/tags//[/...]` pure URL transform
`/checkin`, `/bigscreen` `410 Gone` + explanation HTML per `specs/deferred.md`

What's new

  • Two in-memory indices on `InMemoryState` (`projectIdByLegacyId`, `buzzIdBySlug`), populated by `indexProject` + `indexProjectBuzz` and cleaned up by the corresponding remove ops.
  • `apps/api/src/plugins/legacy-redirect.ts`: onRequest hook pattern-matching the five shapes + the two 410 paths. Bypasses `/api/*`. `Cache-Control: max-age=86400` — legacy URL shapes are permanent.
  • Companion to slug-redirect (renames within the new site); the two hooks match disjoint URL shapes and coexist without coordination.

Unknown legacy-IDs and unknown buzz slugs fall through to the SPA rather than 410 — we don't claim "this used to exist" for inputs we can't verify.

Test plan

  • 19 new test cases in `apps/api/tests/legacy-redirect.test.ts` (all 5 patterns + 410 for both Gone paths + /api/* bypass + unknown-legacyId pass-through + sub-route + query-string preservation). All pass.
  • 274/274 API tests pass (255 pre-existing + 19 new); `npm run type-check && npm run lint` clean.
  • Sandbox smoke (deferred to deploy) — exercise each pattern against next-v2.codeforphilly.org with real laddr URL shapes; confirm 301s land on canonical targets and Google/Slack inbound links work.

Closes #78.

🤖 Generated with Claude Code

themightychris and others added 4 commits May 28, 2026 09:28
Five redirect patterns + a 410 carve-out per
behaviors/legacy-id-mapping.md → "Legacy URL forms we accept". Without
this, every external bookmark / Google-indexed result / Slack-shared
link to the old laddr URL shape 404s at flip-time.

Plan covers two new in-memory indices (projectIdByLegacyId, buzzIdBySlug),
the onRequest hook pattern-matching the 5 shapes + the 2 deferred-page
410 targets, and tests. Companion to #80 (slug-history redirect) —
that one handles renames within the new site; this one handles
inbound legacy URLs from the old one.

Closes #78.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two new in-memory maps powering the legacy-redirect plugin:

  - projectIdByLegacyId: Map<number, string>
    Populated by indexProject when record.legacyId is set.
    Lookup for /projects?ID=<n> and /project-updates?ProjectID=<n>.

  - buzzIdBySlug: Map<string, string>
    Populated by indexProjectBuzz (buzz slugs are globally unique per
    data-model.md#projectbuzz). Lookup for /project-buzz/<slug>.

indexProjectBuzz now mirrors indexProject + indexPerson — reads the old
record before re-indexing so a buzz slug change doesn't leak a stale
buzzIdBySlug entry. The corresponding StateApply.removeProject and
removeProjectBuzz ops clean up the new indices too.

People don't need a legacy-id index because /people/:username → /members/:slug
is a static prefix rewrite (laddr's Username was copied verbatim into
slug per behaviors/slug-handles.md#migration-from-laddr).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
onRequest hook catching the URL shapes the old codeforphilly.org site
served and 301ing them to canonical equivalents per
specs/behaviors/legacy-id-mapping.md:

  /projects?ID=<n>               → /projects/<slug>
  /people/:username[/...]        → /members/:username[/...]
  /project-updates?ProjectID=<n> → /projects/<slug>
  /project-buzz/<slug>[/...]     → /projects/<projectSlug>/buzz/<slug>[/...]
  /tags/<namespace>.<slug>[/...] → /tags/<namespace>/<slug>[/...]

Plus 410 Gone with a minimal HTML explanation for /checkin and
/bigscreen — explicitly-deferred features per specs/deferred.md.

Cache-Control: max-age=86400 (24h) — legacy URL shapes are permanent.

Companion to slug-redirect (renames within the new site); the two
hooks pattern-match disjoint URL shapes and coexist without coordination.
Both bypass /api/* and register before static-web's SPA fallthrough.

19 new test cases cover all five patterns + 410s + the /api/* bypass +
unknown-legacyId pass-through + sub-route + query-string preservation.
274/274 API tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Closeout: flip to done, tick all validations (19 new tests + 274/274
API tests, lint + type-check clean), fill Notes (removeProject /
removeProjectBuzz needed legacy-index cleanup too; indexProjectBuzz
gained an upsert-on-replace lookup; 24h Cache-Control for permanent
redirects; unknown legacyIds pass through rather than 410) + Follow-ups
(polished 410 page, more 410 targets, cutover smoke).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@themightychris themightychris merged commit c434bba into main May 28, 2026
1 check passed
@themightychris themightychris deleted the feat/legacy-url-redirects branch May 28, 2026 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

behavior: legacy laddr URL redirects (/projects?ID=, /people/:username, /tags dot-form, 410 Gone)

1 participant