diff --git a/.eslintignore b/.eslintignore index 69c9dd6bea..d0809e8650 100644 --- a/.eslintignore +++ b/.eslintignore @@ -50,7 +50,6 @@ /packages/medusa/src/api/routes/store/auth /packages/medusa/src/api/routes/store/carts /packages/medusa/src/api/routes/store/customers -/packages/medusa/src/api/routes/store/products /packages/medusa/src/api/routes/store/regions /packages/medusa/src/api/routes/store/return-reasons diff --git a/packages/medusa/src/api/routes/store/products/list-products.js b/packages/medusa/src/api/routes/store/products/list-products.js index 602b028a8c..2c3e364385 100644 --- a/packages/medusa/src/api/routes/store/products/list-products.js +++ b/packages/medusa/src/api/routes/store/products/list-products.js @@ -1,4 +1,3 @@ -import { MedusaError, Validator } from "medusa-core-utils" import { defaultRelations } from "." /** @@ -30,30 +29,26 @@ import { defaultRelations } from "." * $ref: "#/components/schemas/product" */ export default async (req, res) => { - try { - const productService = req.scope.resolve("productService") + const productService = req.scope.resolve("productService") - const limit = parseInt(req.query.limit) || 100 - const offset = parseInt(req.query.offset) || 0 + const limit = parseInt(req.query.limit) || 100 + const offset = parseInt(req.query.offset) || 0 - const selector = {} + const selector = {} - if ("is_giftcard" in req.query && req.query.is_giftcard === "true") { - selector.is_giftcard = req.query.is_giftcard === "true" - } - - selector.status = ["published"] - - const listConfig = { - relations: defaultRelations, - skip: offset, - take: limit, - } - - const products = await productService.list(selector, listConfig) - - res.json({ products, count: products.length, offset, limit }) - } catch (error) { - throw error + if ("is_giftcard" in req.query && req.query.is_giftcard === "true") { + selector.is_giftcard = req.query.is_giftcard === "true" } + + selector.status = ["published"] + + const listConfig = { + relations: defaultRelations, + skip: offset, + take: limit, + } + + const products = await productService.list(selector, listConfig) + + res.json({ products, count: products.length, offset, limit }) } diff --git a/packages/medusa/src/api/routes/store/products/search.js b/packages/medusa/src/api/routes/store/products/search.js index f589ba75fe..e9a4303001 100644 --- a/packages/medusa/src/api/routes/store/products/search.js +++ b/packages/medusa/src/api/routes/store/products/search.js @@ -16,20 +16,16 @@ export default async (req, res) => { throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details) } - try { - const { q, offset, limit, filter, ...options } = value - const paginationOptions = { offset, limit } + const { q, offset, limit, filter, ...options } = value + const paginationOptions = { offset, limit } - const searchService = req.scope.resolve("searchService") + const searchService = req.scope.resolve("searchService") - const results = await searchService.search(ProductService.IndexName, q, { - paginationOptions, - filter, - additionalOptions: options, - }) + const results = await searchService.search(ProductService.IndexName, q, { + paginationOptions, + filter, + additionalOptions: options, + }) - res.status(200).send(results) - } catch (error) { - throw error - } + res.status(200).send(results) }