Переглянути джерело

Added a comment to the edit endpoint, finshing all todos

main
Roxie Gibson 4 роки тому
джерело
коміт
4c85df345f
Не вдалося знайти GPG ключ що відповідає даному підпису
2 змінених файлів з 12 додано та 2 видалено
  1. +12
    -1
      src/api.ts
  2. +0
    -1
      src/index.ts

+ 12
- 1
src/api.ts Переглянути файл

@@ -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,

+ 0
- 1
src/index.ts Переглянути файл

@@ -1,4 +1,3 @@

import { runServer } from "./api";
// TODO: Add logging to endpoints and general running for sysadmin
runServer();

Завантаження…
Відмінити
Зберегти