- Nov dnevni scheduler (server/scheduler.ts): vsak dan ob zagonu in vsakih 6h preveri/generira horoskope in kozmicne dogodke (prej samo enkrat ob zagonu) - Kozmicni dogodki so zdaj AI-generirani in dnevni (nova tabela cosmic_events + /api/cosmic-events), namesto hardcoded fiksnih datumov iz feb/mar 2026 - Naslovni horoskop widget bere pravi AI horoskop za danes (prej staticni tekst) - Frontend: staleTime 30min + refetchOnWindowFocus za dnevno osvezevanje
97 lines
3.5 KiB
TypeScript
97 lines
3.5 KiB
TypeScript
import { sql } from "drizzle-orm";
|
|
import { pgTable, text, varchar, integer, boolean, timestamp, serial } from "drizzle-orm/pg-core";
|
|
import { createInsertSchema } from "drizzle-zod";
|
|
import { z } from "zod";
|
|
|
|
export const articles = pgTable("articles", {
|
|
id: serial("id").primaryKey(),
|
|
title: text("title").notNull(),
|
|
slug: varchar("slug", { length: 255 }).notNull().unique(),
|
|
excerpt: text("excerpt").notNull(),
|
|
content: text("content").notNull(),
|
|
coverImage: text("cover_image"),
|
|
category: varchar("category", { length: 100 }).notNull().default("News"),
|
|
author: varchar("author", { length: 255 }).notNull().default("Folx Music Television"),
|
|
featured: boolean("featured").notNull().default(false),
|
|
views: integer("views").notNull().default(0),
|
|
publishedAt: timestamp("published_at").notNull().defaultNow(),
|
|
});
|
|
|
|
export const insertArticleSchema = createInsertSchema(articles).omit({
|
|
id: true,
|
|
views: true,
|
|
publishedAt: true,
|
|
});
|
|
|
|
export type InsertArticle = z.infer<typeof insertArticleSchema>;
|
|
export type Article = typeof articles.$inferSelect;
|
|
|
|
export const articleViews = pgTable("article_views", {
|
|
id: serial("id").primaryKey(),
|
|
articleId: integer("article_id").notNull(),
|
|
ipHash: varchar("ip_hash", { length: 64 }).notNull(),
|
|
viewedAt: timestamp("viewed_at").notNull().defaultNow(),
|
|
});
|
|
|
|
export const dailyHoroscopes = pgTable("daily_horoscopes", {
|
|
id: serial("id").primaryKey(),
|
|
signIndex: integer("sign_index").notNull(),
|
|
signName: varchar("sign_name", { length: 50 }).notNull(),
|
|
dateStr: varchar("date_str", { length: 10 }).notNull(),
|
|
general: text("general").notNull(),
|
|
love: text("love").notNull(),
|
|
career: text("career").notNull(),
|
|
health: text("health").notNull(),
|
|
tip: text("tip").notNull(),
|
|
weekly: text("weekly").notNull(),
|
|
monthly: text("monthly").notNull(),
|
|
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
});
|
|
|
|
export type DailyHoroscope = typeof dailyHoroscopes.$inferSelect;
|
|
|
|
export const cosmicEvents = pgTable("cosmic_events", {
|
|
id: serial("id").primaryKey(),
|
|
dateStr: varchar("date_str", { length: 10 }).notNull(),
|
|
position: integer("position").notNull(),
|
|
title: varchar("title", { length: 120 }).notNull(),
|
|
description: text("description").notNull(),
|
|
dateRange: varchar("date_range", { length: 120 }).notNull(),
|
|
icon: varchar("icon", { length: 20 }).notNull(),
|
|
type: varchar("type", { length: 20 }).notNull(),
|
|
affectedSigns: text("affected_signs").notNull(),
|
|
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
});
|
|
|
|
export type CosmicEvent = typeof cosmicEvents.$inferSelect;
|
|
|
|
export const users = pgTable("users", {
|
|
id: varchar("id").primaryKey().default(sql`gen_random_uuid()`),
|
|
username: text("username").notNull().unique(),
|
|
password: text("password").notNull(),
|
|
});
|
|
|
|
export const insertUserSchema = createInsertSchema(users).pick({
|
|
username: true,
|
|
password: true,
|
|
});
|
|
|
|
export type InsertUser = z.infer<typeof insertUserSchema>;
|
|
export type User = typeof users.$inferSelect;
|
|
|
|
export const pushSubscriptions = pgTable("push_subscriptions", {
|
|
id: serial("id").primaryKey(),
|
|
endpoint: text("endpoint").notNull().unique(),
|
|
p256dh: text("p256dh").notNull(),
|
|
auth: text("auth").notNull(),
|
|
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
});
|
|
|
|
export const insertPushSubscriptionSchema = createInsertSchema(pushSubscriptions).omit({
|
|
id: true,
|
|
createdAt: true,
|
|
});
|
|
|
|
export type InsertPushSubscription = z.infer<typeof insertPushSubscriptionSchema>;
|
|
export type PushSubscription = typeof pushSubscriptions.$inferSelect;
|