adding mini msg board

Squashed commit of the following:

commit 5e685faff0
Author: Mike Smith <89040888+smiggiddy@users.noreply.github.com>
Date:   Wed Jan 1 20:39:19 2025 -0500

    feat: mobile styling

commit 30a4ac6326
Author: Mike Smith <89040888+smiggiddy@users.noreply.github.com>
Date:   Wed Jan 1 16:51:53 2025 -0500

    another test

commit b847c0f231
Author: Mike Smith <89040888+smiggiddy@users.noreply.github.com>
Date:   Wed Jan 1 16:48:29 2025 -0500

    fix: cf header

commit acc580fb79
Author: Mike Smith <89040888+smiggiddy@users.noreply.github.com>
Date:   Wed Jan 1 16:46:22 2025 -0500

    feat: add client ip tracking

commit 289b95d957
Author: Mike Smith <89040888+smiggiddy@users.noreply.github.com>
Date:   Wed Jan 1 16:40:49 2025 -0500

    feat: add footer and styling

commit eda40eb113
Author: Mike Smith <89040888+smiggiddy@users.noreply.github.com>
Date:   Wed Jan 1 14:59:35 2025 -0500

    feat: added a comment section

commit 27840f3537
Author: Mike Smith <89040888+smiggiddy@users.noreply.github.com>
Date:   Tue Dec 31 14:45:21 2024 -0500

    css: black color

commit 3c3deda986
Author: Mike Smith <89040888+smiggiddy@users.noreply.github.com>
Date:   Tue Dec 31 14:29:00 2024 -0500

    ui: better design and stuff

commit cd43c949aa
Author: Mike Smith <89040888+smiggiddy@users.noreply.github.com>
Date:   Sat Dec 28 17:47:39 2024 -0500

    fix: styling

commit 8c0a4a773e
Author: Mike Smith <89040888+smiggiddy@users.noreply.github.com>
Date:   Sat Dec 28 14:32:07 2024 -0500

    styling added + better templates

commit 0a21838c91
Author: Mike Smith <89040888+smiggiddy@users.noreply.github.com>
Date:   Fri Dec 27 22:33:44 2024 -0500

    fix: create tables

commit 77832d73de
Author: Mike Smith <89040888+smiggiddy@users.noreply.github.com>
Date:   Fri Dec 27 22:21:48 2024 -0500

    dockerfile_update

commit 90769c9bf1
Author: Mike Smith <89040888+smiggiddy@users.noreply.github.com>
Date:   Fri Dec 27 22:17:36 2024 -0500

    more code

commit e07590d6e5
Author: Mike Smith <89040888+smiggiddy@users.noreply.github.com>
Date:   Thu Dec 26 08:15:00 2024 -0500

    updates

commit 1d28883841
Author: Mike Smith <89040888+smiggiddy@users.noreply.github.com>
Date:   Thu Dec 26 07:38:38 2024 -0500

    updated docker file

commit eb3068af96
Author: Mike Smith <89040888+smiggiddy@users.noreply.github.com>
Date:   Thu Dec 26 07:27:38 2024 -0500

    added dockerfile

commit 15a77883f4
Author: Mike Smith <89040888+smiggiddy@users.noreply.github.com>
Date:   Wed Dec 25 22:45:54 2024 -0500

    basic msg board
This commit is contained in:
Smigz 2025-01-01 21:54:34 -05:00
parent b66089f97e
commit 59a08e23a9
23 changed files with 3198 additions and 0 deletions

View file

@ -0,0 +1,50 @@
const db = require("../db");
async function getAllMessages() {
return new Promise((resolve) => {
db.all("SELECT * FROM messages ORDER BY date DESC;", async (err, rows) =>
resolve(rows),
);
});
}
async function getMessageById(id) {
return new Promise((resolve) => {
db.get("SELECT * FROM messages WHERE id = (?)", [id], async (err, rows) => {
resolve(rows);
});
});
}
async function insertMessage(msg) {
db.run("INSERT INTO messages (message, username, date) VALUES ($1, $2, $3)", [
msg.message,
msg.username,
msg.date,
]);
}
async function getAllCommentsForMessage(msgId) {
return new Promise((resolve) => {
db.all(
"SELECT * FROM COMMENTS WHERE message_id = (?)",
[msgId],
async (err, rows) => resolve(rows),
);
});
}
async function insertComment(msgId, comment) {
db.run("INSERT INTO comments (comment, message_id) VALUES ($1, $2)", [
comment,
msgId,
]);
}
module.exports = {
getMessageById,
getAllMessages,
insertMessage,
getAllCommentsForMessage,
insertComment,
};

View file

@ -0,0 +1,26 @@
const db = require("../db");
const SQL = `
CREATE TABLE IF NOT EXISTS messages (
id INTEGER PRIMARY KEY ASC,
message TEXT,
username VARCHAR(25),
date NUMBER
);
INSERT INTO messages (message, username, date)
VALUES
('this is cool', 'smig.tech', '1735391440168.0'),
('I like this app', 'smigz', '1733577117'),
('For real, it is nice', 'mikey', '1735391626')
`;
async function main(db) {
console.log("seeding db...");
db.serialize(() => {
db.exec(SQL);
});
}
main(db);