feat(candidate_profile): add pagination and sort to CV section list endpoints (#73) - #106
Merged
Merged
Conversation
…ndpoints (#73) GET /api/v1/{education|experience|award|certificate|project|reference} now accept optional `page`, `limit`, `sort` query params. Backward compatible by design: omitting `limit` returns the exact same response as before (`data` is the full, unpaginated array). Passing a valid `limit` switches `data` to `{ items, pagination: { page, limit, total, totalPages } }`. `limit` is capped at 100 regardless of what's requested. `sort` accepts a Mongoose sort expression (e.g. `-createdAt`) validated against an allowlist regex (no $, can't smuggle an operator); an invalid value is silently ignored rather than erroring. - services/index.ts: baseFindDocument gains page/limit/sort, applies .sort()/.skip()/.limit() + a parallel countDocuments() only when a valid limit is given - candidate_profile/BaseController.ts: baseGetAll parses page/limit/sort from req.query, validates sort against an allowlist - swagger.config.ts: shared PageParam/LimitParam/SortParam + Pagination schema - 6 CV-section routers (education/experience/award/certificate/project/ reference): wired the new query params into their GET / swagger docs. generalInformation excluded — its GET / returns a single per-candidate document, not a list, so pagination doesn't apply. - tests: baseFindDocument.test.ts, BaseController.test.ts Closes #73
This was referenced Sep 5, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GET /api/v1/{education|experience|award|certificate|project|reference}now accept optionalpage,limit,sortquery params.generalInformationis intentionally excluded — itsGET /returns a single per-candidate document (not a list viabaseGetAll), so pagination doesn't apply there.Backward compatibility
limit→ response is identical to today:datais the full, unpaginated array.limit→databecomes{ items, pagination: { page, limit, total, totalPages } }.limitis capped at 100 regardless of what's requested.sortaccepts a Mongoose sort expression (e.g.-createdAtfor descending), validated against an allowlist regex (no$, can't smuggle an operator) — an invalid value is silently ignored rather than erroring.Changes
services/index.ts:baseFindDocumentgainspage/limit/sort; applies.sort()/.skip()/.limit()plus a parallelcountDocuments(), but only when a validlimitis givencandidate_profile/BaseController.ts:baseGetAllparsespage/limit/sortfromreq.query, validatessortagainst an allowlistswagger.config.ts: sharedPageParam/LimitParam/SortParam+PaginationschemaGET /Swagger docsbaseFindDocument.test.ts,BaseController.test.tsTesting
npm test— 65/65 passingnpx tsc --noEmit— cleanCloses #73
🤖 Generated with Claude Code
https://claude.ai/code/session_01ACpXY4MGdQHFTmu3SZTPLG