Repository navigation
Description
🧭 Project Area
Backend / API
📝 Issue Summary and Problem Description
Issue summary:
The backend document module provides endpoints for listing (GET /api/documents), uploading (POST /api/documents), verifying (PATCH /api/documents/:id/verify), and deleting (DELETE /api/documents/:id). However, there is no endpoint to fetch details of a single document by its ID.
Problem description:
If a client attempts to fetch metadata for a single document via GET /api/documents/:id, the request fails with a generic HTTP 404 ROUTE_NOT_FOUND error instead of a resource lookup response.
Why this is important:
Single resource retrieval is a core RESTful API convention required for document detail pages, auditing, and deep linking within the CertiVault platform.
Who is affected:
Frontend developers building document preview modals or detail views, and API consumers needing single document metadata.
🔍 Current and Expected Behaviour
Current behaviour:
GET /api/documents/demo-credential returns HTTP 404 ROUTE_NOT_FOUND ("Route GET /api/documents/demo-credential was not found").
Current result:
Single document details cannot be queried individually by ID.
Expected behaviour:
GET /api/documents/:id should look up the document in documentStore. If found, return HTTP 200 with { data: document }. If not found, return HTTP 404 with DOCUMENT_NOT_FOUND.
Expected result:
GET /api/documents/demo-credential returns 200 OK with the document payload.
🧩 Reproduction and Evidence
Step 1: Start backend (`npm run dev`)
Step 2: Send GET request to `http://localhost:5000/api/documents/demo-credential`
Step 3: Observe 404 ROUTE_NOT_FOUND error
Step 4: Check document.routes.js — no GET /:id route exists🎯 Affected Scope
Affected files:
- backend/src/modules/documents/document.controller.js
- backend/src/modules/documents/document.routes.js
- backend/tests/integration/app.test.js
Affected APIs: GET /api/documents/:id
Database changes required? No
🖥 Environment
Operating system: Windows 11
Node.js version: v22.x
Package manager: npm 10.x
Deployment environment: Local development
💡 Solution, Alternatives, and Estimate
Priority: P2 Medium
Proposed solution:
- Export
getDocumentcontroller function indocument.controller.jsusingdocumentStore.find(req.params.id). - Register
documentRouter.get("/:id", getDocument)indocument.routes.js. - Add integration tests verifying HTTP 200 (success path) and HTTP 404 (non-existent ID).
Alternative solutions: Client could filter the full GET /api/documents array, but this is inefficient and bad for bandwidth as document count grows.
Difficulty: Beginner
Estimated time: 30 minutes
Dependencies or blockers: None
✅ Acceptance Criteria and Additional Notes
- GET /api/documents/:id returns 200 OK with document data when ID exists
- GET /api/documents/:id returns 404 DOCUMENT_NOT_FOUND when ID does not exist
- Integration tests added to app.test.js covering both success and 404 cases
- All existing 18 tests continue to pass
🤝 Contributor Checklist
- I have searched existing issues and pull requests for duplicates.
- I can reproduce the issue, or I have clearly explained why reproduction is not applicable.
- I will follow the contribution guidelines and target
ecsoc-2026. - I agree to follow the Code of Conduct.
- I have removed secrets, private documents, and personal data.
Activity
Prathvikmehra commentedon Jul 28, 2026
/claim
test(documents): add integration tests for GET /api/documents/:id aut…