-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Implement functionality to update an existing distribution by ID. This involves adding an update method to the service, defining a DTO or validation schema for incoming payloads, and exposing the controller method with routing.
Folder Structure
src/
├──component/
│ ├──v1
│ ├──Distribution
│ ├── Distribution.entity.ts
│ ├── Distribution.service.ts
│ ├── Distribution.controller.ts
│ ├── Distribution.routes.ts
Scope of Work
- Endpoint
PATCH /distributions/:id
Allows partial updates to a distribution
- Service: updateDistribution
Create a method to:
Find the distribution by id
Apply incoming field updates
Persist changes to the database
Return updated entity
-
Controller:
Add a controller method to:
Accept PATCH requests at /distributions/:id
Extract id from the URL
Validate and parse request body
Pass data to the service method
Return response with 200 OK or appropriate error -
DTO or Schema Validation:
Create a DTO or schema for update input (optional fields)
Ensure type safety and validation (e.g., enum validation for status, numeric checks)
- Routing:
Register the PATCH endpoint in your routing layer (e.g., using @patch(':id') in NestJS).
Acceptance Criteria
- Proper input validation (DTO/schema) should be enforced
- Error handling and response standardization should follow project conventions
- You may stub out additional logic (e.g., metadata parsing) and implement in future issues
- Return Response Json Object with
{data: {}, success: boolan, message?: string }