|
|
@@ -119,7 +119,17 @@ async function createProductEndpoint(req: Request, res: Response): Promise<void> |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// TODO: COMMENT |
|
|
|
/** |
|
|
|
* Edits an existing product, either partially or entirely based of user input |
|
|
|
* |
|
|
|
* ~~Responses~~ |
|
|
|
* `200 OK` on success. |
|
|
|
* `400 Bad Request` if unable to parse some or all of the data received for updating. |
|
|
|
* `401 Unauthorized` on request without header `X-Token` being set to an authorized key. |
|
|
|
* `404 Not Found` if product with identifier doesn't exist. |
|
|
|
* @param req - request object |
|
|
|
* @param res - response object |
|
|
|
*/ |
|
|
|
async function editProductEndpoint(req: Request, res: Response): Promise<void> { |
|
|
|
const appendObject = (object1: object, object2: object) => { |
|
|
|
return {...object1, ...object2}; |
|
|
@@ -129,6 +139,7 @@ async function editProductEndpoint(req: Request, res: Response): Promise<void> { |
|
|
|
let updateData = {}; |
|
|
|
let failedValidation: boolean = false; |
|
|
|
|
|
|
|
// One downside to this is it has hardcoded the values away from the actual class. Maybe revise this later. |
|
|
|
const keys: Record<string, any> = { |
|
|
|
"identifier": Product.stringIsUrlSafe, |
|
|
|
"name": Product.stringIsValid, |