Initial commit
This commit is contained in:
23
api/hooks/product/get_read.js
Normal file
23
api/hooks/product/get_read.js
Normal file
@@ -0,0 +1,23 @@
|
||||
const { attachRatingObjsToProduct } = require("./helper")
|
||||
;(function () {
|
||||
if (context.user.auth()) return
|
||||
const bigCommerceProductId = context.request().query("bigCommerceProductId")
|
||||
if (bigCommerceProductId) {
|
||||
/**@type {LocalProduct[]} */
|
||||
//@ts-ignore
|
||||
let products = context.db.find("bigCommerceProduct", {
|
||||
filter: {
|
||||
bigCommerceId: Number(bigCommerceProductId),
|
||||
},
|
||||
})
|
||||
products = attachRatingObjsToProduct(products)
|
||||
|
||||
if (products.length > 0) {
|
||||
throw {
|
||||
status: 200,
|
||||
data: products[0],
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
})()
|
||||
Reference in New Issue
Block a user