24 lines
674 B
JavaScript
24 lines
674 B
JavaScript
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
|
|
})()
|