BETTERZON-143: Fixing API endpoints that didn't return a json

This commit is contained in:
Patrick Müller 2021-06-14 20:54:54 +02:00
parent 6eaf7aca82
commit 1bb05a1baf
6 changed files with 16 additions and 16 deletions

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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.'}));
}

View File

@ -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.'}));

View File

@ -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);