bigly-chat/client/user.js
2024-10-30 20:37:20 -04:00

36 lines
No EOL
872 B
JavaScript

import Route from "../route.js";
import comment from "./comment.js";
import initDb from "../db.js";
let db = await initDb();
let main = new Route([comment], async function (req, res, input) {
let { id } = req.query;
let videos = await db.all('SELECT * FROM video WHERE username = ? ORDER BY date DESC', [
req.query.id
]);
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
]);
let user = await db.all('SELECT * FROM user WHERE username = ?', [
req.query.id
]);
return res.render('user', {
...input,
id,
videos,
followers,
following,
user,
icon: `${process.env.URL}/pfp/${id}.png`
});
});
export default main;