mirror of
https://github.com/Mueller-Patrick/Betterzon.git
synced 2024-11-12 17:43:57 +00:00
Merge pull request #80 from Mueller-Patrick/BETTERZON-143
BETTERZON-143: Fixing API endpoints that didn't return a json
This commit is contained in:
commit
3dbcc6707c
|
@ -89,9 +89,9 @@ 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(201);
|
||||
res.status(201).send({});
|
||||
} else {
|
||||
res.sendStatus(500);
|
||||
res.status(500).send({});
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('Error handling a request: ' + e.message);
|
||||
|
@ -118,9 +118,9 @@ contactpersonsRouter.put('/:id', async (req: Request, res: Response) => {
|
|||
const success = await ContactPersonService.updateContactEntry(user.user_id, contact_person_id, vendor_id, first_name, last_name, gender, email, phone);
|
||||
|
||||
if (success) {
|
||||
res.sendStatus(200);
|
||||
res.status(200).send({});
|
||||
} else {
|
||||
res.sendStatus(500);
|
||||
res.status(500).send({});
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('Error handling a request: ' + e.message);
|
||||
|
|
|
@ -28,7 +28,7 @@ crawlingstatusRouter.get('/', async (req: Request, res: Response) => {
|
|||
const user = await UserService.checkSessionWithCookie(req.cookies.betterauth, user_ip);
|
||||
|
||||
if (!user.is_admin) {
|
||||
res.sendStatus(403);
|
||||
res.status(403).send({});
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -117,9 +117,9 @@ 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(201);
|
||||
res.status(201).send({});
|
||||
} else {
|
||||
res.sendStatus(500);
|
||||
res.status(500).send({});
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('Error handling a request: ' + e.message);
|
||||
|
|
|
@ -120,7 +120,7 @@ productsRouter.post('/', async (req: Request, res: Response) => {
|
|||
const result: boolean = await ProductService.addNewProduct(asin);
|
||||
|
||||
if (result) {
|
||||
res.sendStatus(201);
|
||||
res.status(201).send({});
|
||||
} else {
|
||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ usersRouter.post('/register', async (req: Request, res: Response) => {
|
|||
res.cookie('betterauth', JSON.stringify({
|
||||
id: session.session_id,
|
||||
key: session.session_key
|
||||
}), {expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 30)}).sendStatus(201);
|
||||
}), {expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 30)}).status(201).send({});
|
||||
} catch (e) {
|
||||
console.log('Error handling a request: ' + e.message);
|
||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
||||
|
@ -83,7 +83,7 @@ usersRouter.post('/login', async (req: Request, res: Response) => {
|
|||
res.cookie('betterauth', JSON.stringify({
|
||||
id: session.session_id,
|
||||
key: session.session_key
|
||||
}), {expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 30)}).sendStatus(200);
|
||||
}), {expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 30)}).status(200).send({});
|
||||
} catch (e) {
|
||||
console.log('Error handling a request: ' + e.message);
|
||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
||||
|
|
12
Backend/src/models/vendors/vendors.router.ts
vendored
12
Backend/src/models/vendors/vendors.router.ts
vendored
|
@ -100,9 +100,9 @@ vendorsRouter.put('/manage/deactivatelisting', async (req: Request, res: Respons
|
|||
const success = await VendorService.deactivateListing(user.user_id, vendor_id, product_id);
|
||||
|
||||
if (success) {
|
||||
res.sendStatus(200);
|
||||
res.status(200).send({});
|
||||
} else {
|
||||
res.sendStatus(500);
|
||||
res.status(500).send({});
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('Error handling a request: ' + e.message);
|
||||
|
@ -123,9 +123,9 @@ vendorsRouter.put('/manage/shop/deactivate/:id', async (req: Request, res: Respo
|
|||
const success = await VendorService.setShopStatus(user.user_id, vendor_id, false);
|
||||
|
||||
if (success) {
|
||||
res.sendStatus(200);
|
||||
res.status(200).send({});
|
||||
} else {
|
||||
res.sendStatus(500);
|
||||
res.status(500).send({});
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('Error handling a request: ' + e.message);
|
||||
|
@ -146,9 +146,9 @@ vendorsRouter.put('/manage/shop/activate/:id', async (req: Request, res: Respons
|
|||
const success = await VendorService.setShopStatus(user.user_id, vendor_id, true);
|
||||
|
||||
if (success) {
|
||||
res.sendStatus(200);
|
||||
res.status(200).send({});
|
||||
} else {
|
||||
res.sendStatus(500);
|
||||
res.status(500).send({});
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('Error handling a request: ' + e.message);
|
||||
|
|
Loading…
Reference in New Issue
Block a user