import { IMarketPlace } from "@nimee/shared-types"; import axios from "axios"; const port = process.env.USER_PORT; const basePath = process.env.IS_LOCAL === "true" ? `http://127.0.0.1:${port}` : "http://user"; const userUrl = `${basePath}/user`; export class MarketplaceClient { async getById(id: string) { const response = await axios.get(`${userUrl}/marketplace/${id}`, { headers: { jwt: `${process.env.JWT_ADMIN}` }, }); return response.data as IMarketPlace; } /** * Marketplace ids differ per environment, so callers that need a fixed set of * marketplaces reference them by domain and resolve the id at runtime. */ async getIdByDomain(domain: string) { const response = await axios.get(`${userUrl}/marketplace/getMarketplaceIdByDomainRegex`, { params: { domain }, }); return (response.data || "") as string; } }