An easy-to-host PDS on the ATProtocol, iPhone and MacOS. Maintain control of your keys and data, always.
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor(relay): eliminate DRY violations across admin route handlers #24

open opened by malpercio.dev targeting main from refactor/dry-route-handlers

Summary#

  • routes/auth.rs — extracts require_admin_token() to replace the 37-line Bearer token auth block that was copy-pasted verbatim into claim_codes, create_account, and create_signing_key; also fixes a pre-existing inconsistency in create_signing_key where inspect_err debug logging for non-UTF-8 auth headers was missing
  • routes/code_gen.rs — moves generate_code() + CODE_LEN/CHARSET constants here from claim_codes and create_account, where they were defined identically
  • routes/test_utils.rs — shares test_state_with_admin_token() instead of duplicating it in each route's test module
  • create_account — consolidates 4 pre-check uniqueness queries into 2 OR EXISTS queries (email and handle each now check both accounts+pending_accounts in a single round-trip); the cross-table checks remain load-bearing since SQLite has no cross-table FK enforcement

Net: 121 insertions, 187 deletions. All 185 tests pass.

Test plan#

  • cargo test passes (185 tests, 0 failures)
  • Auth: missing/wrong/bare token still returns 401 on all three admin endpoints
  • POST /v1/accounts still returns 409 for email duplicate in accounts table (cross-table check preserved)
  • POST /v1/accounts still returns 409 for handle duplicate in handles table (cross-table check preserved)
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:web:malpercio.dev/sh.tangled.repo.pull/3mgvlr47xwz22
Diff #0

No differences found between the selected revisions.

History

1 round 0 comments
sign up or login to add to the discussion
malpercio.dev submitted #0
patch application failed: error: No valid patches in input (allow with "--allow-empty")
expand 0 comments