deleting videos, 404
This commit is contained in:
parent
b38fb151ac
commit
62645ddd93
8 changed files with 67 additions and 5 deletions
23
form/delete_video.js
Normal file
23
form/delete_video.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
import Route from "../route.js";
|
||||
import initDb from "../db.js";
|
||||
import { randomUUID } from 'node:crypto';
|
||||
import auth from "../form/auth.js";
|
||||
|
||||
let db = await initDb();
|
||||
|
||||
// TODO: rewrite
|
||||
let main = new Route([auth], async function (req, res, input) {
|
||||
let { username } = input;
|
||||
|
||||
let { target } = req.body;
|
||||
if (!target ) return { 'success': false, 'message': 'Some fields are missing' }; // probably should not re-use these strings
|
||||
|
||||
await db.run('DELETE FROM video WHERE id = ? AND username = ?', [
|
||||
target,
|
||||
username
|
||||
]);
|
||||
|
||||
return { 'message': 'Video deleted', 'success': true};
|
||||
});
|
||||
|
||||
export default main;
|
Loading…
Add table
Add a link
Reference in a new issue