Add support for displaying video advertisement metadata

Integrate Bunny.net API to fetch and display video ad spots, including type, duration, and priority, on the video page. Define new database schema for video ads and create API endpoints for retrieving ad information.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: d7424866-83d1-4486-a212-ac12b4c7becf
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/d7424866-83d1-4486-a212-ac12b4c7becf/jsdCVZt
This commit is contained in:
sebastjanartic
2025-08-28 16:47:09 +00:00
parent ba6cf17bfc
commit 4e4fe369c1
5 changed files with 254 additions and 0 deletions
+27
View File
@@ -81,6 +81,24 @@ export const videoTags = pgTable("video_tags", {
tagId: varchar("tag_id").notNull().references(() => tags.id, { onDelete: "cascade" }),
});
// Video ads/spots table for storing advertisement metadata
export const videoAds = pgTable("video_ads", {
id: varchar("id").primaryKey().default(sql`gen_random_uuid()`),
videoId: varchar("video_id").notNull().references(() => videos.id, { onDelete: "cascade" }),
adType: text("ad_type").notNull(), // preroll, midroll, postroll
adUrl: text("ad_url").notNull(), // VAST URL or direct video URL
adTitle: text("ad_title"),
adDuration: integer("ad_duration"), // in seconds
position: integer("position").default(0), // for midroll ads - position in video (seconds)
skipAfter: integer("skip_after"), // seconds after which ad can be skipped
vastTag: text("vast_tag"), // VAST XML tag URL
adNetwork: text("ad_network"), // network name (e.g., Google AdX, Publift)
isActive: boolean("is_active").default(true).notNull(),
priority: integer("priority").default(1), // ad priority (1 = highest)
createdAt: timestamp("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
updatedAt: timestamp("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`),
});
// Schemas for form validation and API
export const insertVideoSchema = createInsertSchema(videos).omit({
id: true,
@@ -116,11 +134,20 @@ export const insertTagSchema = createInsertSchema(tags).omit({
createdAt: true,
});
export const insertVideoAdSchema = createInsertSchema(videoAds).omit({
id: true,
createdAt: true,
updatedAt: true,
});
// Type exports
export type Video = typeof videos.$inferSelect;
export type InsertVideo = z.infer<typeof insertVideoSchema>;
export type UpdateVideo = z.infer<typeof updateVideoSchema>;
export type VideoAd = typeof videoAds.$inferSelect;
export type InsertVideoAd = z.infer<typeof insertVideoAdSchema>;
export type User = typeof users.$inferSelect;
export type InsertUser = z.infer<typeof insertUserSchema>;