Initial commit: Club DynaSQY
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
const mysql = require('mysql2/promise');
|
||||
require('dotenv').config();
|
||||
|
||||
const pool = mysql.createPool({
|
||||
host: process.env.DB_HOST || 'localhost',
|
||||
port: parseInt(process.env.DB_PORT, 10) || 3306,
|
||||
user: process.env.DB_USER || 'club_dynasqy',
|
||||
password: process.env.DB_PASSWORD || '',
|
||||
database: process.env.DB_NAME || 'club_dynasqy',
|
||||
charset: 'utf8mb4',
|
||||
waitForConnections: true,
|
||||
connectionLimit: 10,
|
||||
queueLimit: 0,
|
||||
});
|
||||
|
||||
module.exports = pool;
|
||||
@@ -0,0 +1,73 @@
|
||||
const nodemailer = require('nodemailer');
|
||||
|
||||
const transporter = nodemailer.createTransport({
|
||||
host: process.env.SMTP_HOST || 'mail.infomaniak.com',
|
||||
port: parseInt(process.env.SMTP_PORT, 10) || 465,
|
||||
secure: parseInt(process.env.SMTP_PORT, 10) === 465 || true,
|
||||
auth: {
|
||||
user: process.env.SMTP_USER,
|
||||
pass: process.env.SMTP_PASS,
|
||||
},
|
||||
});
|
||||
|
||||
async function sendInvitationEmail(guest, inviter, token, baseUrl) {
|
||||
const link = `${baseUrl}/invitation/${token}`;
|
||||
const dateStr = guest.date_club
|
||||
? new Date(guest.date_club).toLocaleDateString('fr-FR', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' })
|
||||
: 'à venir';
|
||||
|
||||
const html = `
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1.0"></head>
|
||||
<body style="margin:0;padding:0;background:#f3f4f6;font-family:Arial,Helvetica,sans-serif;">
|
||||
<table role="presentation" width="100%" cellpadding="0" cellspacing="0">
|
||||
<tr><td style="padding:40px 20px;">
|
||||
<table role="presentation" width="480" align="center" cellpadding="0" cellspacing="0" style="background:#fff;border-radius:16px;overflow:hidden;box-shadow:0 2px 12px rgba(0,0,0,.08);">
|
||||
<tr><td style="background:#1e3a5f;padding:24px;text-align:center;">
|
||||
<h1 style="color:#fff;margin:0;font-size:22px;">Dyna Biz Coignieres</h1>
|
||||
</td></tr>
|
||||
<tr><td style="padding:32px 28px;">
|
||||
<p style="margin:0 0 16px;font-size:16px;color:#333;">Bonjour <strong>${guest.prenom} ${guest.nom}</strong>,</p>
|
||||
<p style="margin:0 0 16px;font-size:15px;color:#555;">
|
||||
${inviter.prenom} ${inviter.nom} de Dyna Biz Coignieres vous invite à participer à notre prochain événement réseau.
|
||||
</p>
|
||||
${guest.date_club ? `<p style="margin:0 0 16px;font-size:15px;color:#555;"><strong>Date :</strong> ${dateStr}</p>` : ''}
|
||||
<p style="margin:0 0 16px;font-size:15px;color:#555;"><strong>Horaires :</strong> 10h45 - 13h00</p>
|
||||
<p style="margin:0 0 16px;font-size:15px;color:#555;"><strong>Lieu :</strong> 7 Av. Roger Hennequin, 78190 Trappes</p>
|
||||
<p style="margin:0 0 24px;font-size:15px;color:#555;">Merci de nous confirmer votre présence en cliquant sur l'un des boutons ci-dessous :</p>
|
||||
<table role="presentation" width="100%" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td align="center" style="padding:0 4px 12px;">
|
||||
<a href="${link}?reponse=acceptee" style="display:inline-block;padding:14px 40px;background:#16a34a;color:#fff;text-decoration:none;border-radius:12px;font-size:16px;font-weight:bold;">J'accepte</a>
|
||||
</td>
|
||||
<td align="center" style="padding:0 4px 12px;">
|
||||
<a href="${link}?reponse=refusee" style="display:inline-block;padding:14px 40px;background:#dc2626;color:#fff;text-decoration:none;border-radius:12px;font-size:16px;font-weight:bold;">Je refuse</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p style="margin:20px 0 0;font-size:13px;color:#888;text-align:center;">
|
||||
Ou rendez-vous sur :<br><a href="${link}" style="color:#1e3a5f;">${link}</a>
|
||||
</p>
|
||||
</td></tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>`;
|
||||
|
||||
try {
|
||||
await transporter.sendMail({
|
||||
from: `"Dyna Biz Coignieres" <${process.env.EMAIL_FROM}>`,
|
||||
to: guest.email,
|
||||
subject: `Invitation - Dyna Biz Coignieres ${guest.date_club ? new Date(guest.date_club).toLocaleDateString('fr-FR') : ''}`,
|
||||
html,
|
||||
});
|
||||
return true;
|
||||
} catch (err) {
|
||||
console.error('Email send error:', err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { transporter, sendInvitationEmail };
|
||||
Reference in New Issue
Block a user