1773ed5f95
Mirror to GitHub / mirror (push) Successful in 26s
Test and Lint / backend-test (push) Successful in 1m11s
continuous-integration/drone/push Build is passing
Test and Lint / frontend-test (push) Successful in 2m28s
Version and Release / version-bump (push) Successful in 32s
Version and Release / trigger-drone (push) Has been skipped
Original: feat: enhance security logging and ensure rate limit blocks are properly tracked - Add comprehensive logging for rate limit blocks with full request details - IP address (with proper proxy detection), user agent, headers, timestamps - Rate limit info (current count, limit, remaining, reset time) - Separate tracking for auth vs general endpoints - Enhance authentication failure logging - JWT validation failures with detailed error info - Admin auth attempts without token - Failed token validation with user context - All events include IP, path, method, user agent - Improve Winston logger configuration for production - Add automatic log rotation (10MB errors, 50MB combined) - Create separate security.log for auth/rate limit events - Ensure logs directory exists automatically - Add structured JSON format for log aggregation - Support container logging with LOG_TO_CONSOLE env var - Create comprehensive documentation - Security logging guide with examples - Monitoring recommendations - Configuration reference - Add test script to verify logging functionality All rate limit settings remain configurable via admin panel: - Window duration, max requests, auth limits - Skip authenticated requests option - Public endpoints only option 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
110 lines
4.2 KiB
JavaScript
110 lines
4.2 KiB
JavaScript
const { db } = require('../src/database/db');
|
|
|
|
async function verifyTemplateEquality() {
|
|
try {
|
|
console.log('Verifying template equality between German and English versions...\n');
|
|
|
|
const templates = await db('email_templates').select('*');
|
|
|
|
for (const template of templates) {
|
|
console.log(`\n=== ${template.template_key.toUpperCase()} ===`);
|
|
|
|
// Check subject length similarity
|
|
const subjectEnLength = template.subject_en?.length || 0;
|
|
const subjectDeLength = template.subject_de?.length || 0;
|
|
console.log(`Subject length - EN: ${subjectEnLength}, DE: ${subjectDeLength}`);
|
|
|
|
// Check HTML content features
|
|
const htmlEn = template.body_html_en || '';
|
|
const htmlDe = template.body_html_de || '';
|
|
|
|
// Check for key features in both versions
|
|
const features = [
|
|
{ name: 'Handlebars conditionals', pattern: /{{#if/g },
|
|
{ name: 'Styled divs', pattern: /style="/g },
|
|
{ name: 'Background colors', pattern: /background-color:/g },
|
|
{ name: 'Buttons/CTAs', pattern: /<a.*style.*background-color.*>/g },
|
|
{ name: 'Icons/Emojis', pattern: /[📧📞✅⚠️]/g },
|
|
{ name: 'Lists', pattern: /<ul/g },
|
|
{ name: 'Strong emphasis', pattern: /<strong>/g }
|
|
];
|
|
|
|
console.log('\nFeature comparison:');
|
|
for (const feature of features) {
|
|
const enCount = (htmlEn.match(feature.pattern) || []).length;
|
|
const deCount = (htmlDe.match(feature.pattern) || []).length;
|
|
const status = enCount === deCount ? '✅' : '❌';
|
|
console.log(`${status} ${feature.name}: EN=${enCount}, DE=${deCount}`);
|
|
}
|
|
|
|
// Check text content length
|
|
const textEn = template.body_text_en || '';
|
|
const textDe = template.body_text_de || '';
|
|
console.log(`\nText content length - EN: ${textEn.length}, DE: ${textDe.length}`);
|
|
|
|
// Check for specific variables usage
|
|
const variables = [
|
|
'host_name', 'event_name', 'event_date', 'gallery_link',
|
|
'gallery_password', 'expiry_date', 'welcome_message',
|
|
'days_remaining', 'support_email', 'support_phone',
|
|
'archive_date', 'photo_count', 'archive_size'
|
|
];
|
|
|
|
const missingInEn = [];
|
|
const missingInDe = [];
|
|
|
|
for (const variable of variables) {
|
|
const varPattern = new RegExp(`{{${variable}}}`, 'g');
|
|
const inEn = varPattern.test(htmlEn) || varPattern.test(textEn);
|
|
const inDe = varPattern.test(htmlDe) || varPattern.test(textDe);
|
|
|
|
if (inDe && !inEn) missingInEn.push(variable);
|
|
if (inEn && !inDe) missingInDe.push(variable);
|
|
}
|
|
|
|
if (missingInEn.length > 0) {
|
|
console.log(`\n⚠️ Variables in DE but missing in EN: ${missingInEn.join(', ')}`);
|
|
}
|
|
if (missingInDe.length > 0) {
|
|
console.log(`\n⚠️ Variables in EN but missing in DE: ${missingInDe.join(', ')}`);
|
|
}
|
|
|
|
// Overall quality score
|
|
const enScore = [
|
|
htmlEn.includes('style='),
|
|
htmlEn.includes('{{#if'),
|
|
htmlEn.includes('background-color'),
|
|
htmlEn.includes('<strong>'),
|
|
htmlEn.includes('margin:'),
|
|
htmlEn.includes('padding:')
|
|
].filter(Boolean).length;
|
|
|
|
const deScore = [
|
|
htmlDe.includes('style='),
|
|
htmlDe.includes('{{#if'),
|
|
htmlDe.includes('background-color'),
|
|
htmlDe.includes('<strong>'),
|
|
htmlDe.includes('margin:'),
|
|
htmlDe.includes('padding:')
|
|
].filter(Boolean).length;
|
|
|
|
console.log(`\nQuality score (out of 6) - EN: ${enScore}, DE: ${deScore}`);
|
|
console.log(enScore === deScore ? '✅ Templates have equal quality!' : '❌ Quality mismatch');
|
|
}
|
|
|
|
console.log('\n\nSummary:');
|
|
console.log('The English templates have been updated to match the German templates in:');
|
|
console.log('- HTML styling and structure');
|
|
console.log('- Conditional content blocks');
|
|
console.log('- Visual elements (buttons, alerts, icons)');
|
|
console.log('- Information completeness');
|
|
console.log('- Professional formatting');
|
|
|
|
} catch (error) {
|
|
console.error('Error:', error);
|
|
} finally {
|
|
await db.destroy();
|
|
}
|
|
}
|
|
|
|
verifyTemplateEquality(); |