fix(admin): trend chart height 100px, logs 3-column layout, KPI cards clickable links, AI timeout 120s env var, X/Pinterest settings
This commit is contained in:
@@ -21,6 +21,8 @@ const updateSettingsSchema = z.object({
|
||||
footerText: z.string().max(400).optional(),
|
||||
facebookUrl: z.string().url().optional().or(z.literal('')),
|
||||
instagramUrl: z.string().url().optional().or(z.literal('')),
|
||||
twitterUrl: z.string().url().optional().or(z.literal('')),
|
||||
pinterestUrl: z.string().url().optional().or(z.literal('')),
|
||||
aiProvider: z.string().max(80).optional(),
|
||||
aiBaseUrl: z.string().url().optional().or(z.literal('')),
|
||||
aiModel: z.string().max(120).optional(),
|
||||
@@ -69,6 +71,8 @@ const SETTING_KEYS: Record<string, string> = {
|
||||
footerText: 'footer_text',
|
||||
facebookUrl: 'facebook_url',
|
||||
instagramUrl: 'instagram_url',
|
||||
twitterUrl: 'twitter_url',
|
||||
pinterestUrl: 'pinterest_url',
|
||||
aiProvider: 'ai_provider',
|
||||
aiBaseUrl: 'ai_base_url',
|
||||
aiModel: 'ai_model',
|
||||
@@ -117,6 +121,8 @@ export async function registerStoreSettingsRoutes(
|
||||
footerText: map['footer_text'] ?? '',
|
||||
facebookUrl: map['facebook_url'] ?? '',
|
||||
instagramUrl: map['instagram_url'] ?? '',
|
||||
twitterUrl: map['twitter_url'] ?? '',
|
||||
pinterestUrl: map['pinterest_url'] ?? '',
|
||||
aiProvider: map['ai_provider'] ?? '',
|
||||
aiBaseUrl: map['ai_base_url'] ?? '',
|
||||
aiModel: map['ai_model'] ?? '',
|
||||
@@ -206,6 +212,8 @@ export async function registerStoreSettingsRoutes(
|
||||
footerText: map['footer_text'] ?? '',
|
||||
facebookUrl: map['facebook_url'] ?? '',
|
||||
instagramUrl: map['instagram_url'] ?? '',
|
||||
twitterUrl: map['twitter_url'] ?? '',
|
||||
pinterestUrl: map['pinterest_url'] ?? '',
|
||||
aiProvider: map['ai_provider'] ?? '',
|
||||
aiBaseUrl: map['ai_base_url'] ?? '',
|
||||
aiModel: map['ai_model'] ?? '',
|
||||
|
||||
@@ -14,4 +14,6 @@ export interface StoreSettings {
|
||||
footerText: string;
|
||||
facebookUrl: string;
|
||||
instagramUrl: string;
|
||||
twitterUrl: string;
|
||||
pinterestUrl: string;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { AppError } from './errors.js';
|
||||
|
||||
/** Default AI timeout: 2 minutes for complex product descriptions */
|
||||
const AI_TIMEOUT_MS = Number.parseInt(process.env.AI_TIMEOUT_MS ?? '120000', 10);
|
||||
|
||||
/**
|
||||
* Shared helpers for AI content generation (OpenAI-compatible chat API)
|
||||
* and HTML formatting of the generated text.
|
||||
@@ -15,7 +18,7 @@ export async function generateWithModel(
|
||||
method: 'POST',
|
||||
headers: { Authorization: `Bearer ${apiKey}`, 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ model, messages: [{ role: 'user', content: prompt }], temperature: 0.4 }),
|
||||
signal: AbortSignal.timeout(30_000),
|
||||
signal: AbortSignal.timeout(AI_TIMEOUT_MS),
|
||||
});
|
||||
const payload = (await response.json().catch(() => null)) as {
|
||||
choices?: Array<{ message?: { content?: unknown } }>;
|
||||
|
||||
Reference in New Issue
Block a user