bigly-chat/client/main.js

22 lines
621 B
JavaScript
Raw Normal View History

2024-11-25 14:12:43 -05:00
import Route from "../route.js";
2024-11-25 14:12:43 -05:00
import auth from "../form/auth.js";
2024-11-25 14:12:43 -05:00
import initDb from "../db.js";
let db = await initDb();
2024-11-25 14:12:43 -05:00
2024-11-25 14:12:43 -05:00
let main = new Route([auth], async function (req, res, input) {
let { username } = input;
2024-11-25 14:12:44 -05:00
let videos = await db.all('SELECT * FROM video ORDER BY date DESC LIMIT 20', [
]);
let videosFollow = await db.all('SELECT * FROM video WHERE username IN (SELECT target FROM follow WHERE username = ?) ORDER BY date DESC LIMIT 20', [
username
2024-11-25 14:12:43 -05:00
]);
2024-11-25 14:12:44 -05:00
res.render('main', {
2024-11-25 14:12:44 -05:00
...input,
2024-11-25 14:12:44 -05:00
videos,
videosFollow
2024-11-25 14:12:43 -05:00
});
2024-11-25 14:12:44 -05:00
return true;
2024-11-25 14:12:43 -05:00
});
export default main;