@@ -17,11 +17,11 @@ import { errorWithResponse } from './http.js';
17
17
/**
18
18
* Load product by SKU
19
19
* @param {Context } ctx - The context object.
20
- * @param {Config } config - The config object.
21
20
* @param {string } sku - The SKU of the product.
22
21
* @returns {Promise<Product> } - A promise that resolves to the product.
23
22
*/
24
- export async function fetchProduct ( ctx , config , sku ) {
23
+ export async function fetchProduct ( ctx , sku ) {
24
+ const { config } = ctx ;
25
25
const { log } = ctx ;
26
26
const key = `${ config . org } /${ config . site } /${ config . storeCode } /${ config . storeViewCode } /products/${ sku } .json` ;
27
27
log . debug ( 'Fetching product from R2:' , key ) ;
@@ -42,11 +42,11 @@ export async function fetchProduct(ctx, config, sku) {
42
42
/**
43
43
* Save products
44
44
* @param {Context } ctx - The context object.
45
- * @param {Config } config - The config object.
46
45
* @param {Product[] } products - The products to save.
47
46
* @returns {Promise<void> } - A promise that resolves when the products are saved.
48
47
*/
49
- export async function saveProducts ( ctx , config , products ) {
48
+ export async function saveProducts ( ctx , products ) {
49
+ const { config } = ctx ;
50
50
const { log } = ctx ;
51
51
const BATCH_SIZE = 50 ;
52
52
@@ -92,11 +92,11 @@ export async function saveProducts(ctx, config, products) {
92
92
/**
93
93
* Resolve SKU from a URL key
94
94
* @param {Context } ctx - The context object.
95
- * @param {Config } config - The config object.
96
95
* @param {string } urlKey - The URL key.
97
96
* @returns {Promise<string> } - A promise that resolves to the SKU.
98
97
*/
99
- export async function lookupSku ( ctx , config , urlKey ) {
98
+ export async function lookupSku ( ctx , urlKey ) {
99
+ const { config } = ctx ;
100
100
// Make a HEAD request to retrieve the SKU from metadata based on the URL key
101
101
const urlKeyPath = `${ config . org } /${ config . site } /${ config . storeCode } /${ config . storeViewCode } /urlkeys/${ urlKey } ` ;
102
102
const headResponse = await ctx . env . CATALOG_BUCKET . head ( urlKeyPath ) ;
@@ -112,10 +112,10 @@ export async function lookupSku(ctx, config, urlKey) {
112
112
/**
113
113
* List all products from R2
114
114
* @param {Context } ctx - The context object.
115
- * @param {Config } config - The config object.
116
115
* @returns {Promise<Product[]> } - A promise that resolves to the products.
117
116
*/
118
- export async function listAllProducts ( ctx , config ) {
117
+ export async function listAllProducts ( ctx ) {
118
+ const { config } = ctx ;
119
119
const bucket = ctx . env . CATALOG_BUCKET ;
120
120
121
121
const listResponse = await bucket . list ( { prefix : `${ config . org } /${ config . site } /${ config . storeCode } /${ config . storeViewCode } /products/` } ) ;
0 commit comments