Nestjs · Easy · Api Contract
The project directory already authenticates callers and returns a stable page of active projects. Its new search box sends a title query, but the endpoint currently ignores that query. Add title matching without changing the existing HTTP contract.
Task
Implement the search predicate and prove through real endpoint tests that title filtering works with the supplied pagination and authorization.
Contract
- Request:
GET /projectsreads the supplied project repository. Query parameters are optional. - Query parameters:
q— title text to search for. Default: empty string. Trim whitespace; maximum length: 80 characters.limit— number of rows requested. Default:20; allowed integers:1..50.offset— number of matching rows to skip. Default:0; allowed integers:0..10000. Numeric parameters must contain digits only. For example,1.5,-1andabcare invalid. - Authentication:
Authorization: Bearer fixture-alphaidentifies tenantalpha;fixture-bravoidentifies tenantbravo. The supplied authentication helper resolves the tenant. A query/body field is not an identity source. - Repository records: Each project has
id,title,tenant,archived,seatsandversion. The fixture provides the data. Use its repository; no external database is required.
Acceptance criteria
- Return HTTP
200with{total, items, nextOffset}. itemscontains only{id, title, seats, version}. Do not expose the internal tenant field.- Keep only the authenticated tenant’s non-archived projects.
- Match the title against the trimmed query without regard to letter case.
- Sort matching projects by ASCII ID before taking the requested page.
totalis the number of all matching projects before pagination, not the page length.- Skip
offsetmatches and return at mostlimititems. nextOffsetisoffset + items.lengthonly when another matching item remains; otherwise it isnull.- An exhausted page has
items: []andnextOffset: null, while keeping the fulltotal. - Invalid query: HTTP
400with{code: "INVALID_QUERY"}. - Missing or unknown bearer token: HTTP
401with{code: "UNAUTHORIZED"}.
Constraints
- At most 10000 projects in the repository; query length at most 80; page size at most 50.
- Use the supplied repository and authenticated tenant resolver. No external database, network service or production credential is needed.
- Directory reads must not mutate stored records or expose the internal tenant field.
- Keep response fields and error codes stable. Do not modify fixtures, manifests or evaluator tests.
Editable files
src/helpers.ts— Implement the title-search predicate used by the real endpoint.tests/candidate.test.js— Add the required regression tests here using fixture(t), assert and node:test.