Skip to content

Chore/brutal code review#43

Merged
divprasad merged 18 commits into
mainfrom
chore/brutal-code-review
Apr 21, 2026
Merged

Chore/brutal code review#43
divprasad merged 18 commits into
mainfrom
chore/brutal-code-review

Conversation

@divprasad

Copy link
Copy Markdown
Owner

No description provided.

- Switched workout sync from upsert by name to find-or-create logic to prevent unique constraint failures
- Fixed Docker HEALTHCHECK IP resolution binding issue in Alpine
Three WebAuthn routes were using bare console.error() which bypassed
the structured file logger (app.log). These routes also had no
logger.request() calls, leaving auth ceremony failures invisible.

- passkey/options/route.ts: add start timer, logger.warn on no-passkey,
  logger.request on all paths, logger.error in catch
- passkey/register/options/route.ts: same pattern
- passkey/register/verify/route.ts: same pattern, plus warn on
  verification failure and expired challenge

All changes follow the established pattern in api/auth/login/route.ts.

Refs: logging_assessment_2026_04_20.md
Admin invite actions (list, generate, revoke) were entirely unlogged.
These are security-relevant events — they control who can register.

Added logger.info() on every successful action and logger.warn() on
all rejection paths (not found, already used). Follows the existing
pattern of using source="admin" for admin-specific events.

Refs: logging_assessment_2026_04_20.md
Client-side errors (console.warn/error) were invisible in production —
no operator could see failures on mobile or after page reload.

This change introduces a durable client error pipeline:
  - ClientError type added to domain.ts
  - Dexie v11: adds clientErrors table (++id index)
  - src/lib/client-logger.ts: structured client logger that writes to
    IndexedDB (best-effort) and mirrors to console
  - src/app/api/client-logs/route.ts: authenticated endpoint that
    receives buffered entries and appends them to app.log as [client]
  - syncEngine.ts: flushClientErrors() wired to the online event
    so buffered errors are delivered on reconnection

Max 100 entries buffered locally. Oldest entries pruned on overflow.
Server validates and caps incoming payload at 100 entries per flush.

Refs: logging_assessment_2026_04_20.md
@divprasad divprasad merged commit 062d6bf into main Apr 21, 2026
9 checks passed
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.

1 participant