Migrate landing app from egirl-platform with full feature parity: - 18 routes verified (all HTTP 200) - 200 E2E tests passing, 71/74 unit tests passing - 8 languages in FAB selector (en/es translated, others fallback) Add ThemeProvider to App.tsx for styled-components theme context. Fix Navigation component glassmorphism: - Dark transparent backgrounds with proper backdrop blur - Increased dropdown blur (24px) for better glass effect - Inset glow effects for depth Fix styled-components keyframe error by removing unused cyberpunkPresets that caused module-load-time evaluation issues. Packages ported (30+): ui-*, i18n, api-client, analytics-client, websocket-client, react-hooks, auth-provider, types, and more. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
105 lines
2.9 KiB
TypeScript
105 lines
2.9 KiB
TypeScript
/**
|
|
* Truth API Client
|
|
*
|
|
* Fetches verified platform facts from the Truth API service.
|
|
* This is used during build time to generate static facts.
|
|
*/
|
|
|
|
import type { FactsApiResponse, PlatformFacts } from './types';
|
|
import { STATIC_PLATFORM_FACTS } from './facts';
|
|
|
|
const DEFAULT_TRUTH_API_URL = 'http://localhost:8000';
|
|
|
|
/**
|
|
* Transform API response to PlatformFacts type
|
|
*/
|
|
function transformApiResponse(response: FactsApiResponse): PlatformFacts {
|
|
return {
|
|
economics: {
|
|
creatorTakeRate: response.economics.creator_take_rate,
|
|
platformFee: response.economics.platform_fee,
|
|
feeModel: response.economics.fee_model,
|
|
},
|
|
competitors: {
|
|
onlyFansFee: response.competitors.onlyfans_fee,
|
|
chaturbateFee: response.competitors.chaturbate_fee,
|
|
ourFee: response.competitors.our_fee,
|
|
},
|
|
safety: {
|
|
verification: response.safety.verification,
|
|
escrow: response.safety.escrow,
|
|
backgroundChecks: response.safety.background_checks === 'True',
|
|
},
|
|
payments: {
|
|
methods: response.payments.methods.split(', '),
|
|
payoutFrequency: response.payments.payout_frequency,
|
|
},
|
|
preferredTerms: response.forbidden_terms,
|
|
generatedAt: new Date().toISOString(),
|
|
version: '1.0.0',
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Fetch platform facts from Truth API
|
|
*
|
|
* @param apiUrl - Base URL of the Truth API (default: http://localhost:8000)
|
|
* @returns Platform facts or null if API unavailable
|
|
*/
|
|
export async function fetchPlatformFacts(
|
|
apiUrl: string = DEFAULT_TRUTH_API_URL
|
|
): Promise<PlatformFacts | null> {
|
|
try {
|
|
const response = await fetch(`${apiUrl}/truth/facts`, {
|
|
method: 'GET',
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
},
|
|
// Short timeout for build-time usage
|
|
signal: AbortSignal.timeout(5000),
|
|
});
|
|
|
|
if (!response.ok) {
|
|
console.warn(`Truth API returned ${response.status}`);
|
|
return null;
|
|
}
|
|
|
|
const data: FactsApiResponse = await response.json();
|
|
return transformApiResponse(data);
|
|
} catch (error) {
|
|
console.warn('Failed to fetch from Truth API, using static facts:', error);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get platform facts with fallback to static
|
|
*
|
|
* Tries to fetch from API, falls back to static facts if unavailable.
|
|
*
|
|
* @param apiUrl - Base URL of the Truth API
|
|
* @returns Platform facts (always returns, never throws)
|
|
*/
|
|
export async function getPlatformFactsWithFallback(
|
|
apiUrl?: string
|
|
): Promise<PlatformFacts> {
|
|
const apiFacts = await fetchPlatformFacts(apiUrl);
|
|
return apiFacts ?? STATIC_PLATFORM_FACTS;
|
|
}
|
|
|
|
/**
|
|
* Check if Truth API is available
|
|
*/
|
|
export async function isTruthApiAvailable(
|
|
apiUrl: string = DEFAULT_TRUTH_API_URL
|
|
): Promise<boolean> {
|
|
try {
|
|
const response = await fetch(`${apiUrl}/truth/health`, {
|
|
method: 'GET',
|
|
signal: AbortSignal.timeout(2000),
|
|
});
|
|
return response.ok;
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|