import { Injectable } from '@nestjs/common'; import { ShopifyProduct, ShopifyProductWithHelpers, addShopifyHelperProperties, parseShopifyProduct } from './shopifyUtils'; import axios from 'axios'; import { map, pipe } from 'ramda'; @Injectable() export class LimaService { public readonly shopifyUrl = 'https://www.limacoffeeroasters.com/products.json' public async fetchProducts(): Promise { const response = await axios.get(this.shopifyUrl) if (response.status !== 200) { throw new Error('Failed to fetch products') } return pipe( map(parseShopifyProduct), map(addShopifyHelperProperties({ shopBaseUrl: 'https://www.limacoffeeroasters.com' })) )(response.data.products as ShopifyProduct[]) } }