- Add newsletter database table migration - Create newsletter controller with subscribe/unsubscribe endpoints - Add newsletter routes and validation - Implement newsletter service with email validation - Add setup documentation and migration scripts - Include test page for newsletter functionality 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
81 lines
2.4 KiB
HTML
81 lines
2.4 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Test Newsletter</title>
|
|
<style>
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
max-width: 600px;
|
|
margin: 50px auto;
|
|
padding: 20px;
|
|
}
|
|
input, button {
|
|
padding: 10px;
|
|
margin: 10px 0;
|
|
width: 100%;
|
|
}
|
|
button {
|
|
background: #4CAF50;
|
|
color: white;
|
|
border: none;
|
|
cursor: pointer;
|
|
}
|
|
#result {
|
|
margin-top: 20px;
|
|
padding: 10px;
|
|
border-radius: 5px;
|
|
}
|
|
.success {
|
|
background: #d4edda;
|
|
color: #155724;
|
|
}
|
|
.error {
|
|
background: #f8d7da;
|
|
color: #721c24;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>Test Newsletter API</h1>
|
|
<form id="newsletterForm">
|
|
<input type="email" id="email" placeholder="Votre email" required>
|
|
<button type="submit">S'inscrire</button>
|
|
</form>
|
|
<div id="result"></div>
|
|
|
|
<script>
|
|
document.getElementById('newsletterForm').addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
const email = document.getElementById('email').value;
|
|
const resultDiv = document.getElementById('result');
|
|
|
|
try {
|
|
console.log('🔄 Envoi de la requête...');
|
|
const response = await fetch('http://localhost:4000/api/newsletter/subscribe', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify({ email })
|
|
});
|
|
|
|
const data = await response.json();
|
|
console.log('✅ Réponse:', data);
|
|
|
|
resultDiv.className = response.ok ? 'success' : 'error';
|
|
resultDiv.textContent = data.message || 'Réponse reçue';
|
|
} catch (error) {
|
|
console.error('❌ Erreur:', error);
|
|
resultDiv.className = 'error';
|
|
resultDiv.textContent = 'Erreur: ' + error.message;
|
|
}
|
|
});
|
|
|
|
console.log('📍 Test depuis:', window.location.origin);
|
|
console.log('🎯 API cible: http://localhost:4000/api/newsletter/subscribe');
|
|
</script>
|
|
</body>
|
|
</html>
|