Update: Bestätigungsseite
This commit is contained in:
59
index.js
59
index.js
@ -2,11 +2,12 @@ const dotenv = require("dotenv");
|
|||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const bodyParser = require('body-parser');
|
const bodyParser = require("body-parser");
|
||||||
const cors = require("cors");
|
const cors = require("cors");
|
||||||
|
|
||||||
const nodemailer = require("nodemailer");
|
const nodemailer = require("nodemailer");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
|
const path = require("path");
|
||||||
|
|
||||||
const transporter = nodemailer.createTransport({
|
const transporter = nodemailer.createTransport({
|
||||||
host: "smtp-relay.brevo.com",
|
host: "smtp-relay.brevo.com",
|
||||||
@ -15,33 +16,39 @@ const transporter = nodemailer.createTransport({
|
|||||||
auth: {
|
auth: {
|
||||||
user: process.env.smtp_user,
|
user: process.env.smtp_user,
|
||||||
pass: process.env.smtp_pass,
|
pass: process.env.smtp_pass,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
const port = 3000;
|
const port = 3000;
|
||||||
|
|
||||||
app.use(cors({
|
app.use(
|
||||||
|
cors({
|
||||||
origin: process.env.origin,
|
origin: process.env.origin,
|
||||||
}))
|
})
|
||||||
|
);
|
||||||
app.use(express.static("assets"));
|
app.use(express.static("assets"));
|
||||||
app.use(bodyParser.urlencoded({ extended: true }));
|
app.use(bodyParser.urlencoded({ extended: true }));
|
||||||
|
|
||||||
app.post("/post", (req, res) => {
|
app.post("/post", (req, res) => {
|
||||||
fs.writeFile(`./data/${req.body.firstname}-${req.body.lastname}.json`, JSON.stringify(req.body), (err) => {
|
fs.writeFile(
|
||||||
console.log(err)
|
`./data/${req.body.firstname}-${req.body.lastname}.json`,
|
||||||
})
|
JSON.stringify(req.body),
|
||||||
|
(err) => {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
transporter.sendMail({
|
transporter.sendMail(
|
||||||
|
{
|
||||||
from: "Alumnihub <alumnihub@kocoder.xyz>",
|
from: "Alumnihub <alumnihub@kocoder.xyz>",
|
||||||
to: `${req.body.firstname} ${req.body.lastname} <${req.body.email}>`,
|
to: `${req.body.firstname} ${req.body.lastname} <${req.body.email}>`,
|
||||||
envelope: {
|
envelope: {
|
||||||
from: "alumnihub@kocoder.xyz",
|
from: "alumnihub@kocoder.xyz",
|
||||||
to: req.body.email,
|
to: req.body.email,
|
||||||
},
|
},
|
||||||
subject: "Anmeldungs für's Absolvententreffen.",
|
subject: "Deine Anmeldung für's Absolvententreffen.",
|
||||||
text:
|
text: `
|
||||||
`
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="de">
|
<html lang="de">
|
||||||
<body style="font-family: Arial, sans-serif; line-height: 1.5;">
|
<body style="font-family: Arial, sans-serif; line-height: 1.5;">
|
||||||
@ -71,25 +78,27 @@ app.post("/post", (req, res) => {
|
|||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
`,
|
`,
|
||||||
}, (err, info) => {
|
},
|
||||||
|
(err, info) => {
|
||||||
if (err) return res.send(err);
|
if (err) return res.send(err);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return res.sendFile("bestaetigung.html", {
|
||||||
|
root: path.join(__dirname, "views"),
|
||||||
});
|
});
|
||||||
return res.send("Du wurdest erfolgreich angemeldet!");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post("/cancel", (req, res) => {
|
app.post("/cancel", (req, res) => {
|
||||||
fs.writeFile(`./data/${req.body.firstname}-${req.body.lastname}.json`, JSON.stringify(req.body), (err) => {
|
transporter.sendMail(
|
||||||
console.log(err)
|
{
|
||||||
})
|
|
||||||
|
|
||||||
transporter.sendMail({
|
|
||||||
from: "Alumnihub <alumnihub@kocoder.xyz>",
|
from: "Alumnihub <alumnihub@kocoder.xyz>",
|
||||||
to: `${req.body.firstname} ${req.body.lastname} <${req.body.email}>`,
|
to: `${req.body.firstname} ${req.body.lastname} <${req.body.email}>`,
|
||||||
envelope: {
|
envelope: {
|
||||||
from: "alumnihub@kocoder.xyz",
|
from: "alumnihub@kocoder.xyz",
|
||||||
to: req.body.email,
|
to: req.body.email,
|
||||||
},
|
},
|
||||||
subject: "Anmeldungs für's Absolvententreffen.",
|
subject: "Deine Absage für's Absolvententreffen.",
|
||||||
text: `
|
text: `
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="de">
|
<html lang="de">
|
||||||
@ -111,12 +120,16 @@ app.post("/cancel", (req, res) => {
|
|||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
`,
|
`,
|
||||||
}, (err, info) => {
|
},
|
||||||
|
(err, info) => {
|
||||||
if (err) return res.send(err);
|
if (err) return res.send(err);
|
||||||
});
|
}
|
||||||
return res.send("Du hast erfolgreich abgesagt !");
|
);
|
||||||
});
|
|
||||||
|
|
||||||
|
return res.sendFile("bestaetigung.html", {
|
||||||
|
root: path.join(__dirname, "views"),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
app.listen(port, () => {
|
app.listen(port, () => {
|
||||||
console.log(`Example app listening on port ${port}`);
|
console.log(`Example app listening on port ${port}`);
|
||||||
|
24
views/bestaetigung.html
Normal file
24
views/bestaetigung.html
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="de">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>Absolvententreffen 2025</title>
|
||||||
|
<link rel="stylesheet" href="styles.css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<img src="logo.png" alt="HTL Ungargasse Logo" class="logo" />
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<main>
|
||||||
|
<h1>Absolvententreffen</h1>
|
||||||
|
<h2>2025</h2>
|
||||||
|
<div class="buttons">
|
||||||
|
Vielen Dank für das hinterlassen der Informationen zu dir und das
|
||||||
|
Interesse am Absolventinnentreffen. Wir werden dich über folgende
|
||||||
|
Veranstaltungen informieren.
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
Reference in New Issue
Block a user