26 lines
No EOL
566 B
JavaScript
26 lines
No EOL
566 B
JavaScript
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
|
|
]);
|
|
|
|
res.render('messages', {
|
|
...input,
|
|
msgs
|
|
});
|
|
return true;
|
|
});
|
|
|
|
export default main; |