Skip to content

Implement PATCH /distributions/:id Endpoint for Updating a Distribution #3

@mubarak23

Description

@mubarak23

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

  1. Endpoint

PATCH /distributions/:id

Allows partial updates to a distribution

  1. Service: updateDistribution

Create a method to:
Find the distribution by id
Apply incoming field updates
Persist changes to the database
Return updated entity

  1. 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

  2. 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)

  1. 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 }

Metadata

Metadata

Labels

Backendonlydust-waveContribute to awesome OSS repos during OnlyDust's open source week

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions