diff --git a/client/src/pages/horoscope.tsx b/client/src/pages/horoscope.tsx
index 58844cf..3053de3 100644
--- a/client/src/pages/horoscope.tsx
+++ b/client/src/pages/horoscope.tsx
@@ -43,6 +43,7 @@ interface AIHoroscope {
tip: string;
weekly: string;
monthly: string;
+ imageUrl?: string | null;
}
function StarRating({ count }: { count: number }) {
@@ -161,6 +162,14 @@ function SignGrid({ onSelect, selectedIndex, aiHoroscopes }: { onSelect: (i: num
}`}
data-testid={`button-sign-grid-${sign.name.toLowerCase()}`}
>
+ {(horoscope as any).imageUrl && (
+
+ )}
{sign.symbol}
@@ -227,6 +236,15 @@ function SignDetail({ signIndex, onNavigate, aiHoroscopes }: { signIndex: number
+ {(horoscope as any).imageUrl && (
+

+ )}
{sign.symbol}
diff --git a/server/horoscope-generator.ts b/server/horoscope-generator.ts
index 55820a3..45b0130 100644
--- a/server/horoscope-generator.ts
+++ b/server/horoscope-generator.ts
@@ -25,6 +25,19 @@ export async function getHoroscopesForToday(): Promise
{
return [];
}
+export async function setHoroscopeImages(dateStr: string, images: Record): Promise {
+ let n = 0;
+ for (const [key, url] of Object.entries(images || {})) {
+ const idx = parseInt(key, 10);
+ if (Number.isNaN(idx) || !url) continue;
+ await db.update(dailyHoroscopes)
+ .set({ imageUrl: url })
+ .where(and(eq(dailyHoroscopes.dateStr, dateStr), eq(dailyHoroscopes.signIndex, idx)));
+ n++;
+ }
+ return n;
+}
+
export async function generateDailyHoroscopes(): Promise {
const today = getTodayStr();
diff --git a/server/routes.ts b/server/routes.ts
index 8e0a6e4..f8716b6 100644
--- a/server/routes.ts
+++ b/server/routes.ts
@@ -3,7 +3,7 @@ import { createServer, type Server } from "http";
import { storage } from "./storage";
import { insertArticleSchema } from "@shared/schema";
import { seedDatabase } from "./seed";
-import { generateDailyHoroscopes, getHoroscopesForToday, getOrGenerateHoroscope, getCosmicEventsForToday, generateCosmicEvents } from "./horoscope-generator";
+import { generateDailyHoroscopes, getHoroscopesForToday, getOrGenerateHoroscope, getCosmicEventsForToday, generateCosmicEvents, setHoroscopeImages } from "./horoscope-generator";
import { startDailyScheduler } from "./scheduler";
import { analyzeAllArticleImages, getCachedFocalPoints } from "./focal-point";
import { optimizeImage } from "./image-optimizer";
@@ -741,6 +741,19 @@ export async function registerRoutes(
});
// Horoscope API
+ app.post("/api/horoscopes/images", requireApiKey, async (req, res) => {
+ try {
+ const { dateStr, images } = req.body || {};
+ if (!dateStr || typeof images !== "object" || images === null) {
+ return res.status(400).json({ message: "dateStr und images sind erforderlich" });
+ }
+ const updated = await setHoroscopeImages(dateStr, images);
+ res.json({ updated });
+ } catch (err: any) {
+ res.status(500).json({ message: err.message });
+ }
+ });
+
app.get("/api/horoscopes/today", async (_req, res) => {
try {
const horoscopes = await getHoroscopesForToday();
diff --git a/shared/schema.ts b/shared/schema.ts
index 18ba3dd..e0ccc77 100644
--- a/shared/schema.ts
+++ b/shared/schema.ts
@@ -45,6 +45,7 @@ export const dailyHoroscopes = pgTable("daily_horoscopes", {
tip: text("tip").notNull(),
weekly: text("weekly").notNull(),
monthly: text("monthly").notNull(),
+ imageUrl: text("image_url"),
createdAt: timestamp("created_at").notNull().defaultNow(),
});