2024-09-20 16:59:12 -04:00
|
|
|
import Route from "../route.js";
|
2024-09-22 03:49:36 -04:00
|
|
|
import comment from "./comment.js";
|
2024-09-20 16:59:12 -04:00
|
|
|
import initDb from "../db.js";
|
|
|
|
|
|
|
|
let db = await initDb();
|
|
|
|
|
2024-09-22 03:49:36 -04:00
|
|
|
let main = new Route([comment], async function (req, res, input) {
|
2024-09-20 16:59:12 -04:00
|
|
|
let { id } = req.query;
|
|
|
|
let videos = await db.all('SELECT * FROM video WHERE username = ? ORDER BY date DESC', [
|
|
|
|
req.query.id
|
|
|
|
]);
|
2024-09-22 10:49:47 -04:00
|
|
|
|
|
|
|
let followers = await db.all('SELECT * FROM follow WHERE target = ?', [
|
|
|
|
req.query.id
|
|
|
|
]);
|
|
|
|
|
|
|
|
let following = await db.all('SELECT * FROM follow WHERE username = ?', [
|
|
|
|
req.query.id
|
|
|
|
]);
|
|
|
|
|
2024-09-27 03:59:23 -04:00
|
|
|
let user = await db.all('SELECT * FROM user WHERE username = ?', [
|
|
|
|
req.query.id
|
|
|
|
]);
|
|
|
|
|
2024-09-20 16:59:12 -04:00
|
|
|
return res.render('user', {
|
2024-09-22 03:49:36 -04:00
|
|
|
...input,
|
2024-09-20 16:59:12 -04:00
|
|
|
id,
|
2024-09-22 10:49:47 -04:00
|
|
|
videos,
|
|
|
|
followers,
|
2024-09-27 03:59:23 -04:00
|
|
|
following,
|
2024-10-30 20:37:20 -04:00
|
|
|
user,
|
|
|
|
icon: `${process.env.URL}/pfp/${id}.png`
|
2024-09-20 16:59:12 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
export default main;
|