BETTERZON-73: Adding API endpoint that returns the lowest non-amazon prices for a given list of product ids (#32)

This commit is contained in:
Patrick
2021-04-29 09:41:11 +02:00
committed by GitHub
parent 9e9b442f35
commit f7c045b5a3
2 changed files with 95 additions and 11 deletions
@@ -82,6 +82,25 @@ pricesRouter.get('/bestDeals/:amount', async (req: Request, res: Response) => {
}
});
// GET prices/byProduct/list/[]
pricesRouter.get('/byProduct/list/:ids', async (req: Request, res: Response) => {
const productIds: [number] = JSON.parse(req.params.ids);
if (!productIds) {
res.status(400).send('Missing parameters.');
return;
}
try {
const prices: Prices = await PriceService.findListByProducts(productIds);
res.status(200).send(prices);
} catch (e) {
res.status(404).send(e.message);
}
});
// POST items/
// pricesRouter.post('/', async (req: Request, res: Response) => {