add comments

This commit is contained in:
biglyderv 2024-11-25 14:12:43 -05:00
parent e8cc01e66f
commit 59c1daeac5
11 changed files with 94 additions and 11 deletions

25
client/comment.js Normal file
View file

@ -0,0 +1,25 @@
import Route from "../route.js";
import auth from "../form/auth.js";
import initDb from "../db.js";
let db = await initDb();
let main = new Route([auth], async function (req, res, input) {
let {route} = req.params;
let {id} = req.query;
let { username } = input;
let comments = await db.all('SELECT * FROM comment WHERE targetType = ? AND targetId = ?', [
route,
id
]);
return {
...input,
route,
id,
comments
};
});
export default main;

View file

@ -1,17 +1,16 @@
import Route from "../route.js";
import auth from "../form/auth.js";
import comment from "./comment.js";
import initDb from "../db.js";
let db = await initDb();
let main = new Route([auth], async function (req, res, input) {
let { username } = input;
let main = new Route([comment], async function (req, res, input) {
let videoData = await db.all('SELECT * FROM video WHERE id = ?', [
req.query.id
]);
videoData = videoData[0];
return res.render('player', {
username,
...input,
videoData
});
});

View file

@ -1,17 +1,16 @@
import Route from "../route.js";
import auth from "../form/auth.js";
import comment from "./comment.js";
import initDb from "../db.js";
let db = await initDb();
let main = new Route([auth], async function (req, res, input) {
let main = new Route([comment], async function (req, res, input) {
let { id } = req.query;
let { username } = input;
let videos = await db.all('SELECT * FROM video WHERE username = ? ORDER BY date DESC', [
req.query.id
]);
return res.render('user', {
username,
...input,
id,
videos
});