-
-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add GET /api/v1/compliance-checklist/{checklistId} endpoint
#248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughA new API endpoint for retrieving a compliance checklist by its ID has been introduced. This includes updates to the API router, OpenAPI specification, and store layer, along with new tests covering successful retrieval, error scenarios, and input validation for the new endpoint. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant API_Router
participant Store
Client->>API_Router: GET /api/v1/compliance-checklist/{checklistId}
API_Router->>Store: getChecklistById(checklistId)
Store-->>API_Router: Checklist data or null
alt Checklist found
API_Router-->>Client: 200 OK + checklist
else Checklist not found
API_Router-->>Client: 404 Not Found
end
Possibly related PRs
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (3)
src/store/index.js (1)
253-255: Consider exposing a genericgetByIdhelper to avoid the proliferation of one-off wrappers
getCheckByIdand the newly addedgetChecklistByIdare thin aliases aroundgetOne(table, id).
As the number of tables grows we risk ending up with many almost-identical wrappers, increasing maintenance overhead without adding real abstraction.- getCheckById: (id) => getOne('compliance_checks', id), - getChecklistById: (id) => getOne('compliance_checklists', id) + /** + * Generic getter for any table by primary key. + * Usage: store.getById('compliance_checks', 42) + */ + getById: (table, id) => getOne(table, id),You can still keep the semantic aliases if you think they improve DX, but having a single canonical entry point will make future additions cheaper and avoid forgetting to wire new tables.
src/httpServer/routers/apiV1.js (1)
30-31: Minor: keep the destructuring alphabetically sorted for readabilityThe destructured list is getting long. Sorting (e.g.
addProject, getAllChecks, getAllChecklists, getChecklistById, …) helps spot duplicates and merge conflicts faster.__tests__/httpServer/apiV1.test.js (1)
466-496: Add tests for0and negative IDs to document the intended behaviourThe suite checks invalid strings and non-existent IDs but not boundary values (
0,-1).
Once the router uses explicit validation (see previous comment) these cases should return 400; capturing them in tests prevents regressions.test('should return 400 for zero checklist ID', async () => { const response = await app.get('/api/v1/compliance-checklist/0') expect(response.status).toBe(400) }) test('should return 400 for negative checklist ID', async () => { const response = await app.get('/api/v1/compliance-checklist/-1') expect(response.status).toBe(400) })
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
__tests__/httpServer/apiV1.test.js(3 hunks)src/httpServer/routers/apiV1.js(2 hunks)src/httpServer/swagger/api-v1.yml(1 hunks)src/store/index.js(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Playwright Tests
🔇 Additional comments (1)
src/httpServer/swagger/api-v1.yml (1)
349-389: Spec looks good – remember to update the server URL examples if neededNo issues with the schema / responses; the
minimum: 1constraint aligns with recommended positive-int validation.
Related #216
Summary by CodeRabbit
New Features
Tests