Add file deleting functionality to the admin panel
This commit is contained in:
@ -8,6 +8,7 @@ import { batchScheduler } from "./services/batch-scheduler.js";
|
||||
import { config, validateConfig } from "./services/config.js";
|
||||
import {
|
||||
deleteFeed,
|
||||
deleteEpisode,
|
||||
fetchAllEpisodes,
|
||||
fetchEpisodesWithArticles,
|
||||
getAllCategories,
|
||||
@ -254,6 +255,33 @@ app.get("/api/admin/episodes/simple", async (c) => {
|
||||
}
|
||||
});
|
||||
|
||||
app.delete("/api/admin/episodes/:id", async (c) => {
|
||||
try {
|
||||
const episodeId = c.req.param("id");
|
||||
|
||||
if (!episodeId || episodeId.trim() === "") {
|
||||
return c.json({ error: "Episode ID is required" }, 400);
|
||||
}
|
||||
|
||||
console.log("🗑️ Admin deleting episode ID:", episodeId);
|
||||
|
||||
const deleted = await deleteEpisode(episodeId);
|
||||
|
||||
if (deleted) {
|
||||
return c.json({
|
||||
result: "DELETED",
|
||||
message: "Episode deleted successfully",
|
||||
episodeId,
|
||||
});
|
||||
} else {
|
||||
return c.json({ error: "Episode not found" }, 404);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error deleting episode:", error);
|
||||
return c.json({ error: "Failed to delete episode" }, 500);
|
||||
}
|
||||
});
|
||||
|
||||
// Database diagnostic endpoint
|
||||
app.get("/api/admin/db-diagnostic", async (c) => {
|
||||
try {
|
||||
|
Reference in New Issue
Block a user