README Fehlerbehebungen

This commit is contained in:
klaas 2024-09-09 17:29:24 +02:00
parent 6dd6f41f8c
commit c273d5d4d6
1 changed files with 17 additions and 14 deletions

17
app.js
View File

@ -410,17 +410,20 @@ app.get("/project/:id", async (req, res) => {
id,
]);
const projekt = result.rows[0];
console.log(`${projekt.repository_link}/raw/branch/main/README.md`);
var htmlContent = projekt.beschreibung;
try {
const url = `${projekt.repository_link}/raw/branch/main/README.md`;
// Abrufen der Datei
const response = await axios.get(url);
// Markdown-Inhalt in HTML umwandeln
const htmlContent = marked(response.data);
htmlContent = marked(response.data);
//const htmlContent = "Testdata";
if (!projekt) {
return res.status(404).send("Projekt nicht gefunden");
}
} catch (err) {
console.error(err);
}
res.render("project", {
projekt,
@ -429,17 +432,17 @@ app.get("/project/:id", async (req, res) => {
});
} catch (err) {
console.error(err);
res.send(err);
}
});
app.post("/projectedit", async (req, res) => {
req.session.message = ["", "", "none"];
const { id, name, beschreibung, repository_link } = req.body;
const { id, name, kurzbeschreibung, beschreibung, repository_link } =
req.body;
try {
await pool.query(
"UPDATE projects SET name = $1, beschreibung = $2 repository_link =$3 WHERE id = $4",
[name, beschreibung, repository_link, id]
"UPDATE projects SET name = $1, kurzbeschreibung = $2, beschreibung = $3, repository_link =$4 WHERE id = $5",
[name, kurzbeschreibung, beschreibung, repository_link, id]
);
} catch (err) {
console.error(err);