fix: api/routes/store/products pass linting (#644)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 })
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user