Added reading profile endpoint

This commit is contained in:
Sven laptop
2026-07-24 23:50:33 +02:00
parent 9e56f00c1e
commit eaeb0a29bc
7 changed files with 45 additions and 5 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ async function create_post(req, res) {
const imageLink = imageLinkForFile(req.file);
try {
const { rows } = await pool.query(
"INSERT INTO posts (title, text, author_id, image_link) VALUES ($1, $2, $3, $4) RETURNING id, title, text, author_id, image_link",
"WITH created AS (INSERT INTO posts (title, text, author_id, image_link) VALUES ($1, $2, $3, $4) RETURNING id, title, text, author_id, image_link, created_at) SELECT created.*, people.username AS author_username FROM created LEFT JOIN people ON people.id = created.author_id",
[title, text, author_id, imageLink],
);
res.status(201).json(rows[0]);