// @ts-check const { withAccount } = require("../lib/utils") ;(function () { /** @type {HookResponse} */ let hookResponse let request = context.request() if (context.user.auth()) return const orderId = Number(request.query("orderId")) if (orderId) { withAccount((login) => { let order = context.db.find("bigCommerceOrder", { filter: { bigCommerceId: orderId, customerBigCommerceId: login.bigCommerceId, }, })[0] if (!order) { throw { status: 404, data: { message: "Order not found", }, } } }) hookResponse = { filter: { bigcommerceOrderId: orderId, }, } return hookResponse } else { hookResponse = { filter: context.filter, selector: { bigCommerceProductId: 1, rating: 1, comment: 1, title: 1, review_date: 1, }, } return hookResponse } })()