bigly-chat/client/messages.js

26 lines
566 B
JavaScript
Raw Normal View History

2024-11-25 14:12:44 -05:00
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 { username } = input;
let msgs = await db.all('SELECT * FROM message WHERE username = ? ORDER BY date DESC', [
username
]);
await db.run('UPDATE message SET read = ? WHERE username = ?', [
'true',
username
]);
2024-11-25 14:12:44 -05:00
res.render('messages', {
2024-11-25 14:12:44 -05:00
...input,
msgs
});
2024-11-25 14:12:44 -05:00
return true;
2024-11-25 14:12:44 -05:00
});
export default main;