Skip to content

Implement POST /distributions Endpoint for Creating a Distribution #2

Description

@mubarak23

Implement the backend functionality to allow users to create a new distribution. This includes defining the entity, setting up the service logic, implementing the controller method, and registering the route.

Folder Structure

src/
├──component/
│   ├──v1
│        ├──Distribution
│            ├── Distribution.entity.ts
│            ├── Distribution.service.ts
│            ├── Distribution.controller.ts


Service: createDistribution

Add a method to handle business logic:

Validate required fields
Calculate derived values if needed (e.g., total_usd_amount)
Persist to the database
Return created record or success response

Controller:

POST /distributions

Accept JSON body with required distribution fields
Call service method
Return response with status 201 Created and distribution ID or details

Routing:

Register the controller method in your routes configuration (e.g., using @post() decorator if using NestJS or express-like router if not).

✳️ 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 }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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