Skip to content

refactor: dedupe event-payload & request-guard helpers; fail lint on warnings - #164

Merged
dev-fani merged 1 commit into
fanilabs:mainfrom
willy-de7:chore/dedupe-helpers-and-lint-maxwarnings
Aug 30, 2026
Merged

refactor: dedupe event-payload & request-guard helpers; fail lint on warnings#164
dev-fani merged 1 commit into
fanilabs:mainfrom
willy-de7:chore/dedupe-helpers-and-lint-maxwarnings

Conversation

@willy-de7

Copy link
Copy Markdown
Contributor

Resolves three small, independently-tracked tech-debt items in one pass. Each is a mechanical change with no runtime behaviour change (except CI strictness in #133).


closes #133pnpm lint never fails on ESLint warnings

"lint": "eslint ." exits 0 for a run that produces only warnings. eslint.config.js has exactly one warn-severity rule (no-console), so a reintroduced console.log in src/ would pass both pnpm lint and CI's lint-and-typecheck job silently.

  • package.json"lint": "eslint . --max-warnings=0", matching the all-or-nothing enforcement of format:check / typecheck / test.

Acceptance

  • pnpm lint now exits non-zero on any warning.

closes #131 — blockchain-event payload parsers copy-pasted across ~7 files

parseAddress was defined verbatim in the application-layer event handlers of deliveries, disputes, escrow, fleet, fraud-detection, notifications, reputation (7 copies). A parallel BigInt-id parser was defined independently in deliveries (parseDeliveryId), escrow (parseDeliveryId), fleet (parseFleetId) and disputes (parseBareDeliveryId).

  • New src/shared/events/parse.ts exporting parseAddress and a single generically-named parseBigIntId, re-exported from the existing src/shared/events barrel (already an allowed dependency for the application layer per eslint.config.js). Lives next to BlockchainEventEnvelope because this is event-payload-shape parsing, not module business logic.
  • All 7 local parseAddress definitions replaced with the shared import.
  • parseDeliveryId / parseFleetId / parseBareDeliveryId call sites now use parseBigIntId; the local definitions are removed.
  • disputes keeps parseTupleWrappedDeliveryId as a thin, contract-specific wrapper — it now JSON-unwraps and delegates to parseBigIntId.
  • notifications keeps parseId (its read model keys by the decimal string form) as a two-line wrapper over parseBigIntId.
  • escrow's parseAmount is left local (amounts, not ids — out of scope).

Acceptance

  • parseAddress defined in exactly one place.
  • Generic BigInt-parsing logic defined in exactly one place; module-specific wrapping (disputes tuple-unwrap, notifications string form) kept local.

closes #132requireUser / requireUserId request-guard copy-pasted across 4 route files

admin, disputes, notifications and users each defined their own near-identical helper (same "unreachable in practice" comment) to narrow request.user after an authenticate preHandler.

  • Added requireUser(request): { id: string; role: UserRole } to src/shared/http/plugins/auth-guard.ts — next to authenticate / requireRole, and to the request.user type augmentation it already declares — and re-exported it from src/shared/http/index.js.
  • Replaced the four local definitions with the shared import. requireUserId(request) call sites become requireUser(request).id.
  • Dropped the now-unused UnauthorizedError (and, in disputes, UserRole) imports from the four route files.

Acceptance

  • Helper defined in exactly one place, exported alongside authenticate / requireRole.

Verification

Pure extraction / mechanical change — no behaviour change. Verified locally that this branch adds zero new pnpm lint, pnpm typecheck, or vitest failures relative to main (the local dev environment has some pre-existing dependency-resolution drift; the diff introduces none of it, and touches no failing file).

…n warnings

Consolidates three small, independently-tracked duplication/tooling gaps.

closes fanilabs#133
closes fanilabs#131
closes fanilabs#132
@drips-wave

drips-wave Bot commented Aug 30, 2026

Copy link
Copy Markdown

@willy-de7 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@dev-fani
dev-fani merged commit 8fc7e62 into fanilabs:main Aug 30, 2026
1 of 2 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

2 participants