This commit is contained in:
2025-06-26 20:05:02 +00:00
parent 7908feebf3
commit c22b86e19f
84 changed files with 234 additions and 3726 deletions

View File

@@ -94,6 +94,49 @@ app.post(
}),
);
app.delete(
"/resources/:filename",
verifyToken,
asyncHandler(async (req, res) => {
try {
const { filename } = req.params;
if (!filename) {
return res.status(400).json({ error: "Filename is required" });
}
// Validate filename format (basic security check)
if (!filename.match(/^F_S\d+T\d+_RV\d+\.md$/)) {
return res.status(400).json({ error: "Invalid filename format" });
}
const filePath = path.join(STATIC_DIR, filename);
// Check if file exists
try {
await fs.access(filePath);
} catch (error) {
return res.status(404).json({ error: "File not found" });
}
// Delete the file
await fs.unlink(filePath);
// Refresh the structure cache
const structure = await getStructure({ refresh: true });
res.json({
success: true,
message: `File ${filename} deleted successfully`,
structure,
});
} catch (error) {
console.log(error);
res.status(500).json({ error: "Failed to delete file" });
}
}),
);
app.use(errorRequestHandler);
const PORT = process.env.PORT || 3000;