add messages
This commit is contained in:
parent
d5daf958cf
commit
a9a0996e77
11 changed files with 220 additions and 10 deletions
25
client/messages.js
Normal file
25
client/messages.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
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
|
||||
]);
|
||||
|
||||
return res.render('messages', {
|
||||
...input,
|
||||
msgs
|
||||
});
|
||||
});
|
||||
|
||||
export default main;
|
Loading…
Add table
Add a link
Reference in a new issue