Skip to content

feat: add parseCreatorId helper and integrate into creator ID handlers (#468) - #501

Merged
Chucks1093 merged 2 commits into
accesslayerorg:mainfrom
K1NGD4VID:ID-param
Jun 27, 2026
Merged

feat: add parseCreatorId helper and integrate into creator ID handlers (#468)#501
Chucks1093 merged 2 commits into
accesslayerorg:mainfrom
K1NGD4VID:ID-param

Conversation

@K1NGD4VID

Copy link
Copy Markdown
Contributor

Summary

Creator ID params arrive as strings from the URL but are stored as integers in the database. Each handler previously coerced the type independently. This PR adds a shared parseCreatorId helper that parses and validates a creator ID string at the start of every handler that accepts a creator ID.

Closes #468

Changes

New: src/utils/creator-id.utils.ts

  • parseCreatorId(raw: string): number — validates input is a positive integer and returns the parsed number. Throws a 400 ApiError (via validationError) for: empty strings, whitespace-only, non-numeric, floats, negatives, and zero.

Modified: src/modules/creators/creators.controllers.ts

  • httpGetCreatorStats — replaced manual req.params.id existence/type check with parseCreatorId(req.params.id)

Modified: src/modules/creators/creator-holders.controller.ts

  • httpGetCreatorHolders — replaced typeof rawId === string ? rawId : String(rawId ?? ) with parseCreatorId(req.params.id)

Modified: src/modules/webhooks/webhook-signature.middleware.ts

  • requireWalletSignature — replaced raw req.params.id extraction + null check with parseCreatorId(req.params.id) (inside try/catch since this middleware lacks async error handling)

New: src/utils/test/creator-id.utils.test.ts

  • 10 unit tests covering: valid integer, trimmed integer, float, negative, non-numeric, empty, whitespace-only, trailing non-digits, zero, and statusCode assertion

Acceptance Criteria

  • Valid positive integer string parses correctly
  • All invalid inputs throw a 400-shaped error
  • Helper used consistently across creator detail, holders, and webhook endpoints

Notes

  • Buyback quote endpoints do not yet exist in the codebase. The helper is ready to be used when they are added.
  • All 10 new unit tests pass. Pre-existing test failures (3 suites) are unrelated to this change (Prisma client generation and implicit any types).

- Add parseCreatorId(raw): number utility that validates positive integer
  and throws 400 ApiError on invalid input
- Replace manual creator ID coercion in creator detail, holders, and
  webhook handlers with the shared helper
- Add unit tests covering valid, float, negative, non-numeric, empty,
  whitespace, trailing chars, and zero edge cases

Closes accesslayerorg#468
@drips-wave

drips-wave Bot commented Jun 26, 2026

Copy link
Copy Markdown

@K1NGD4VID 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

@Chucks1093
Chucks1093 merged commit b527e4b into accesslayerorg:main Jun 27, 2026
1 check 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.

Add helper for normalizing creator ID param to consistent type before database lookup

2 participants