This commit is contained in:
@@ -6,6 +6,9 @@ INITIAL_ADMIN_PASSWORD=
|
||||
INITIAL_SELLER_NAME=
|
||||
MFA_ENCRYPTION_KEY=
|
||||
PRICING_FIXTURE_PROVIDER_ENABLED=false
|
||||
PRICING_HTTP_PROVIDER_ID=http-provider
|
||||
PRICING_HTTP_PROVIDER_ENDPOINT=
|
||||
PRICING_HTTP_PROVIDER_TOKEN=
|
||||
PASSWORD_RESET_URL=http://localhost:5173/reset-password
|
||||
SMTP_FROM=no-reply@example.test
|
||||
SMTP_URL=smtp://localhost:1025
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { createPricingProvider } from './pricing-provider.js';
|
||||
|
||||
export function createHttpPricingProvider({
|
||||
id,
|
||||
endpoint,
|
||||
token,
|
||||
fetchImplementation = fetch,
|
||||
}) {
|
||||
if (typeof endpoint !== 'string' || endpoint.trim().length === 0) {
|
||||
throw new Error('Pricing provider endpoint is required.');
|
||||
}
|
||||
|
||||
return createPricingProvider({
|
||||
id,
|
||||
async observe(input) {
|
||||
const url = new URL(endpoint);
|
||||
for (const [key, value] of Object.entries(input)) {
|
||||
if (value) url.searchParams.set(key, value);
|
||||
}
|
||||
const response = await fetchImplementation(url, {
|
||||
headers: token ? { authorization: `Bearer ${token}` } : {},
|
||||
});
|
||||
if (!response.ok) throw new Error(`Pricing provider returned HTTP ${response.status}.`);
|
||||
const payload = await response.json();
|
||||
return payload?.observations ?? payload;
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE "pricing_refresh_jobs" ADD COLUMN "external_identifier" text;
|
||||
ALTER TABLE "pricing_refresh_jobs" ADD COLUMN "search_query" text;
|
||||
Reference in New Issue
Block a user