From d362c68fac0c682ba06f925b428896038b55fc1f Mon Sep 17 00:00:00 2001 From: Patrick <50352812+Mueller-Patrick@users.noreply.github.com> Date: Sun, 30 May 2021 12:07:08 +0200 Subject: [PATCH] BETTERZON-126: Correcting HTTP status codes sent by API (#72) --- Backend/src/models/contact_persons/contact_persons.router.ts | 2 +- Backend/src/models/pricealarms/pricealarms.router.ts | 4 ++-- Backend/src/models/prices/prices.router.ts | 2 +- Backend/src/models/users/users.router.ts | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Backend/src/models/contact_persons/contact_persons.router.ts b/Backend/src/models/contact_persons/contact_persons.router.ts index bb2d1a0..85c8035 100644 --- a/Backend/src/models/contact_persons/contact_persons.router.ts +++ b/Backend/src/models/contact_persons/contact_persons.router.ts @@ -89,7 +89,7 @@ contactpersonsRouter.post('/', async (req: Request, res: Response) => { const success = await ContactPersonService.createContactEntry(user.user_id, vendor_id, first_name, last_name, gender, email, phone); if (success) { - res.sendStatus(200); + res.sendStatus(201); } else { res.sendStatus(500); } diff --git a/Backend/src/models/pricealarms/pricealarms.router.ts b/Backend/src/models/pricealarms/pricealarms.router.ts index cc42032..fcd4939 100644 --- a/Backend/src/models/pricealarms/pricealarms.router.ts +++ b/Backend/src/models/pricealarms/pricealarms.router.ts @@ -85,11 +85,11 @@ pricealarmsRouter.put('/', async (req: Request, res: Response) => { return; } - // Create price alarm + // Update price alarm const success = await PriceAlarmsService.updatePriceAlarm(alarm_id, user.user_id, defined_price); if (success) { - res.status(201).send(JSON.stringify({success: true})); + res.status(200).send(JSON.stringify({success: true})); return; } else { res.status(500).send(JSON.stringify({success: false})); diff --git a/Backend/src/models/prices/prices.router.ts b/Backend/src/models/prices/prices.router.ts index 047ce1b..6d3d389 100644 --- a/Backend/src/models/prices/prices.router.ts +++ b/Backend/src/models/prices/prices.router.ts @@ -117,7 +117,7 @@ pricesRouter.post('/', async (req: Request, res: Response) => { const success = await PriceService.createPriceEntry(user.user_id, vendor_id, product_id, price_in_cents); if (success) { - res.sendStatus(200); + res.sendStatus(201); } else { res.sendStatus(500); } diff --git a/Backend/src/models/users/users.router.ts b/Backend/src/models/users/users.router.ts index db28a93..fe67f1b 100644 --- a/Backend/src/models/users/users.router.ts +++ b/Backend/src/models/users/users.router.ts @@ -105,7 +105,7 @@ usersRouter.post('/checkSessionValid', async (req: Request, res: Response) => { } // Send the session details back to the user - res.status(201).send(user); + res.status(200).send(user); } catch (e) { console.log('Error handling a request: ' + e.message); res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));