trails/apps/journal/app/routes
Ullrich Schäfer 4de6c86d41
fix(journal): architectural audit omnibus
Addresses 8 issues from the Journal architecture audit:

1. DB indexes on routes.ownerId + activities.ownerId. Listing queries on
   these tables were full table scans; adds composite indexes matching
   the order-by columns (updatedAt/startedAt/createdAt).
2. Zod validation on /api/auth/register body. Previously the action
   destructured request.json() with zero schema validation.
3. N+1 GeoJSON batch fetch collapsed to a single ANY($1::text[]) query
   in both routes.server and activities.server.
4. Webhook envelope validation in /api/sync/webhook/:provider.
5. AbortSignal.timeout(30s) on all external fetches (Komoot, Wahoo) via
   a new fetchWithTimeout helper in lib/http.server.ts.
6. .limit(100) on listPublicRoutesForOwner / listPublicActivitiesForOwner.
9. Welcome email moved off fire-and-forget onto a pg-boss job with
   retryLimit: 3 (send-welcome-email).
10. process.env.ORIGIN ?? "http://localhost:3000" centralized into
    lib/config.server.ts::getOrigin() across 14 call sites.

Issues 7 (centralized apiError/auth guards across 60+ route files) and
8 (split .server.ts boundaries across 20+ route files) intentionally
deferred — both are pure refactors that would balloon this PR past
reviewability and warrant their own focused PRs.

Tests added:
- lib/config.server.test.ts (2 cases)
- lib/http.server.test.ts (3 cases — timeout abort, success passthrough,
  caller-signal composition)
- routes/api.sync.webhook.$provider.test.ts (6 cases)
- routes/api.auth.register.test.ts (7 cases — schema rejection paths +
  the new welcome-email enqueue assertion)

Full repo: pnpm typecheck, pnpm lint, pnpm test all green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-24 10:28:33 +02:00
..
activities.$id.tsx Drop auth.server.ts re-exports + rename to .server.ts convention (task 5.2) 2026-05-08 03:01:30 +02:00
activities._index.tsx Add activity sort toggle on activities page 2026-05-23 18:21:04 +02:00
activities.new.tsx Drop auth.server.ts re-exports + rename to .server.ts convention (task 5.2) 2026-05-08 03:01:30 +02:00
api.auth.login.ts fix(journal): architectural audit omnibus 2026-05-24 10:28:33 +02:00
api.auth.register.test.ts fix(journal): architectural audit omnibus 2026-05-24 10:28:33 +02:00
api.auth.register.ts fix(journal): architectural audit omnibus 2026-05-24 10:28:33 +02:00
api.e2e.komoot.ts Rewrite komoot E2E tests to use server-side seed endpoint 2026-05-23 10:57:16 +02:00
api.e2e.route.$id.ts Fix unused import lint error in api.e2e.route.$id.ts 2026-05-10 15:24:31 +02:00
api.e2e.seed.ts Show POI details (phone, website, opening hours) on Journal route detail page 2026-05-17 23:32:38 +02:00
api.events.ts Drop auth.server.ts re-exports + rename to .server.ts convention (task 5.2) 2026-05-08 03:01:30 +02:00
api.follows.$id.approve.ts Drop auth.server.ts re-exports + rename to .server.ts convention (task 5.2) 2026-05-08 03:01:30 +02:00
api.follows.$id.reject.ts Drop auth.server.ts re-exports + rename to .server.ts convention (task 5.2) 2026-05-08 03:01:30 +02:00
api.metrics.ts Add observability: health endpoints, structured logging, metrics, Grafana stack 2026-03-26 22:59:44 +01:00
api.notifications.$id.read.ts Drop auth.server.ts re-exports + rename to .server.ts convention (task 5.2) 2026-05-08 03:01:30 +02:00
api.notifications.read-all.ts Drop auth.server.ts re-exports + rename to .server.ts convention (task 5.2) 2026-05-08 03:01:30 +02:00
api.routes.$id.callback.ts Atomic GPX save: validate + persist row + geometry in one transaction 2026-05-10 15:02:56 +02:00
api.routes.$id.edit-in-planner.ts fix(journal): architectural audit omnibus 2026-05-24 10:28:33 +02:00
api.routes.$id.gpx.ts Add route detail day segment highlighting and per-day GPX export 2026-04-11 00:44:11 +02:00
api.settings.delete-account.ts Drop auth.server.ts re-exports + rename to .server.ts convention (task 5.2) 2026-05-08 03:01:30 +02:00
api.settings.email.ts fix(journal): architectural audit omnibus 2026-05-24 10:28:33 +02:00
api.settings.passkey.delete.ts Drop auth.server.ts re-exports + rename to .server.ts convention (task 5.2) 2026-05-08 03:01:30 +02:00
api.settings.profile.ts Drop auth.server.ts re-exports + rename to .server.ts convention (task 5.2) 2026-05-08 03:01:30 +02:00
api.sync.callback.$provider.ts fix(journal): architectural audit omnibus 2026-05-24 10:28:33 +02:00
api.sync.connect.$provider.ts fix(journal): architectural audit omnibus 2026-05-24 10:28:33 +02:00
api.sync.disconnect.$provider.ts Simplify: typed status, skip-write guard, remove redundant comment 2026-05-23 20:49:09 +02:00
api.sync.komoot.connect.ts Add Komoot import with public (bio verification) and authenticated modes 2026-05-23 10:18:46 +02:00
api.sync.komoot.import-status.ts Add background bulk import for Komoot 2026-05-23 18:19:10 +02:00
api.sync.komoot.import.ts Add background bulk import for Komoot 2026-05-23 18:19:10 +02:00
api.sync.komoot.verify.ts fix(journal): architectural audit omnibus 2026-05-24 10:28:33 +02:00
api.sync.push.$provider.$routeId.ts fix(journal): architectural audit omnibus 2026-05-24 10:28:33 +02:00
api.sync.webhook.$provider.test.ts fix(journal): architectural audit omnibus 2026-05-24 10:28:33 +02:00
api.sync.webhook.$provider.ts fix(journal): architectural audit omnibus 2026-05-24 10:28:33 +02:00
api.users.$username.follow.ts Drop auth.server.ts re-exports + rename to .server.ts convention (task 5.2) 2026-05-08 03:01:30 +02:00
api.users.$username.unfollow.ts Drop auth.server.ts re-exports + rename to .server.ts convention (task 5.2) 2026-05-08 03:01:30 +02:00
api.v1.activities.$id.ts Implement Journal REST API v1 endpoints 2026-04-13 00:57:27 +02:00
api.v1.activities._index.ts DRY up ZodError → FieldError mapping 2026-04-19 11:45:09 +02:00
api.v1.auth.devices.$id.ts Implement Journal REST API v1 endpoints 2026-04-13 00:57:27 +02:00
api.v1.auth.devices.ts Implement Journal REST API v1 endpoints 2026-04-13 00:57:27 +02:00
api.v1.routes.$id.ts DRY up ZodError → FieldError mapping 2026-04-19 11:45:09 +02:00
api.v1.routes._index.ts DRY up ZodError → FieldError mapping 2026-04-19 11:45:09 +02:00
api.v1.routes.compute.ts Session-bind /api/route and /api/overpass 2026-04-21 22:18:45 +02:00
api.v1.routes.test.ts fix: enforce Terms gate on bearer-token API requests 2026-05-08 01:59:28 +02:00
api.v1.test.ts Add unit tests for REST API validation and pagination 2026-04-13 00:58:18 +02:00
api.v1.uploads.ts DRY up ZodError → FieldError mapping 2026-04-19 11:45:09 +02:00
api.well-known.trails-cool.test.ts Implement OAuth2 PKCE auth, discovery, and mobile API client 2026-04-13 00:41:40 +02:00
api.well-known.trails-cool.ts fix(journal): architectural audit omnibus 2026-05-24 10:28:33 +02:00
auth.accept-terms.tsx Drop auth.server.ts re-exports + rename to .server.ts convention (task 5.2) 2026-05-08 03:01:30 +02:00
auth.login.tsx Implement completeAuth chokepoint + caller migration 2026-05-08 02:38:15 +02:00
auth.logout.tsx Drop auth.server.ts re-exports + rename to .server.ts convention (task 5.2) 2026-05-08 03:01:30 +02:00
auth.register.tsx Implement completeAuth chokepoint + caller migration 2026-05-08 02:38:15 +02:00
auth.verify.tsx Drop auth.server.ts re-exports + rename to .server.ts convention (task 5.2) 2026-05-08 03:01:30 +02:00
explore.tsx Drop auth.server.ts re-exports + rename to .server.ts convention (task 5.2) 2026-05-08 03:01:30 +02:00
feed.tsx Drop auth.server.ts re-exports + rename to .server.ts convention (task 5.2) 2026-05-08 03:01:30 +02:00
follows.requests.tsx Merge /follows/requests into /notifications as a tabbed inbox 2026-04-26 08:24:59 +02:00
home.tsx Drop auth.server.ts re-exports + rename to .server.ts convention (task 5.2) 2026-05-08 03:01:30 +02:00
legal.imprint.tsx Apply minimal legal-review follow-ups 2026-04-19 07:27:56 +02:00
legal.privacy.tsx Add Komoot import with public (bio verification) and authenticated modes 2026-05-23 10:18:46 +02:00
legal.terms.tsx Store Terms version alongside acceptance timestamp 2026-04-19 07:46:34 +02:00
notifications.tsx Drop auth.server.ts re-exports + rename to .server.ts convention (task 5.2) 2026-05-08 03:01:30 +02:00
oauth.authorize.tsx Drop auth.server.ts re-exports + rename to .server.ts convention (task 5.2) 2026-05-08 03:01:30 +02:00
oauth.token.ts Implement Journal REST API v1 endpoints 2026-04-13 00:57:27 +02:00
privacy.tsx Add legal pages, ToS acceptance, and alpha banner 2026-04-18 00:08:48 +02:00
routes.$id.edit.tsx Drop auth.server.ts re-exports + rename to .server.ts convention (task 5.2) 2026-05-08 03:01:30 +02:00
routes.$id.tsx Propagate waypoint notes through session init, save-to-journal, and Journal display 2026-05-18 20:52:12 +02:00
routes._index.tsx Drop auth.server.ts re-exports + rename to .server.ts convention (task 5.2) 2026-05-08 03:01:30 +02:00
routes.new.tsx Drop auth.server.ts re-exports + rename to .server.ts convention (task 5.2) 2026-05-08 03:01:30 +02:00
settings._index.tsx Split /settings into 4 sub-pages with a sidebar layout 2026-04-26 09:48:00 +02:00
settings.account.tsx Drop auth.server.ts re-exports + rename to .server.ts convention (task 5.2) 2026-05-08 03:01:30 +02:00
settings.connections.komoot.tsx fix(journal): architectural audit omnibus 2026-05-24 10:28:33 +02:00
settings.connections.tsx Add Komoot import with public (bio verification) and authenticated modes 2026-05-23 10:18:46 +02:00
settings.profile.tsx Drop auth.server.ts re-exports + rename to .server.ts convention (task 5.2) 2026-05-08 03:01:30 +02:00
settings.security.tsx Drop auth.server.ts re-exports + rename to .server.ts convention (task 5.2) 2026-05-08 03:01:30 +02:00
settings.tsx Drop auth.server.ts re-exports + rename to .server.ts convention (task 5.2) 2026-05-08 03:01:30 +02:00
sync.import.$provider.tsx Fix import-all skipping every other workout 2026-05-23 13:00:43 +02:00
sync.import.komoot.tsx Add background bulk import for Komoot 2026-05-23 18:19:10 +02:00
users.$username.followers.tsx Drop auth.server.ts re-exports + rename to .server.ts convention (task 5.2) 2026-05-08 03:01:30 +02:00
users.$username.following.tsx Drop auth.server.ts re-exports + rename to .server.ts convention (task 5.2) 2026-05-08 03:01:30 +02:00
users.$username.tsx Add activity sort toggle on user profile page 2026-05-23 18:06:06 +02:00