Hack-The-Tunnels-8 / hack-the-tunnels-oreo

hack-the-tunnels-oreo created by GitHub Classroom
0 stars 0 forks source link

Update Product Endpoint #18

Closed hackthetunnelsbot[bot] closed 1 year ago

hackthetunnelsbot[bot] commented 1 year ago

Description:

Create an admin only accesible endpoint for updating one or many attributes of a product. (PUT /products/:id)

You will need to edit the following files:

Add a new PUT /products/:id route on service/src/infrastructure/api/routes/products.ts

You will need to create a new update function on service/src/services/Product.ts which your new route on products.ts will call.

You will also need to stop non admins from using this endpoint. Checkout the createProduct function on service/src/infrastructure/api/routes/products.ts for an example of how to verify a user has authorization to products.

Acceptance Criteria:

There is a new endpoint that allows you to update a product under PUT /api/v1/products/:id that is only accesible when the Authorization header is properly set.

The endpoint should update all the attributes present in the request body.

Ex: Will just update the product's title

{
    "title": "test",
}

Ex: Will update both the product's description and price

{
    "description": "test",
    "price": 1.99
}
VictorOkenne commented 1 year ago

!review

Asianadian commented 1 year ago

!approve

hackthetunnelsbot[bot] commented 1 year ago

Approved by @Asianadian

hackthetunnelsbot[bot] commented 1 year ago

This challenge did not unlock any other challenges