Enable users to edit video titles, descriptions, and thumbnails
Introduce functionality to edit video metadata including title, description, category, tags, and public status, along with a new modal for editing and a backend endpoint for updating video information. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 11420304-80a9-4ef2-adff-cbdaa418ffa8 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/11420304-80a9-4ef2-adff-cbdaa418ffa8/vOcB2tQ
This commit is contained in:
@@ -2,6 +2,7 @@ import type { Express } from "express";
|
||||
import { createServer, type Server } from "http";
|
||||
import { storage } from "./storage";
|
||||
import { z } from "zod";
|
||||
import { updateVideoSchema } from "@shared/schema";
|
||||
|
||||
export async function registerRoutes(app: Express): Promise<Server> {
|
||||
// Get videos with pagination and filtering
|
||||
@@ -47,6 +48,25 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
}
|
||||
});
|
||||
|
||||
// Update video metadata (title, description, etc.)
|
||||
app.patch("/api/videos/:id", async (req, res) => {
|
||||
try {
|
||||
const updates = updateVideoSchema.parse(req.body);
|
||||
const updatedVideo = await storage.updateVideo(req.params.id, updates);
|
||||
|
||||
if (!updatedVideo) {
|
||||
return res.status(404).json({ message: "Video not found" });
|
||||
}
|
||||
|
||||
res.json(updatedVideo);
|
||||
} catch (error) {
|
||||
if (error instanceof z.ZodError) {
|
||||
return res.status(400).json({ message: "Invalid request data", errors: error.errors });
|
||||
}
|
||||
res.status(500).json({ message: "Failed to update video" });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user