feat: tüm mock veriyi kaldır + Resend e-posta entegrasyonu
- mockTenders.js silindi; referans listeleri (sektör/il/kurum) constants.js'e taşındı - AppContext: tenders/liveStats/competitorWatchlist/vaultDocuments/notifications/ savedFilters/apiKeys/scrapedCapabilities → gerçek/boş; sahte Math.random online sayacı kaldırıldı; competitor & belge kasası artık localStorage - LiveStatsBar: gerçek alanlar (canlı havuz/yüklü/bugün/kalem/takibimdeki) - AnalyticsDashboard: KPI'lar (katılım/kazanma oranı/kazanılan bedel) + aylık hacim + sektörel dağılım gerçek companyStats/monthlyStats/sectorStats'tan; ciro hedefi kullanıcı tarafından belirlenir; veri yoksa dürüst boş durum - ContractSearch & Rakip Radar: gerçek firmStats - analytics.js: companyStats/monthlyStats/parseDateTR eklendi - Resend: server/email.mjs + /api/notify/email/config + /api/notify/email/test (auth'lu, kullanıcının kendi adresine); PwaSettings gerçek e-posta test kartı
This commit is contained in:
@@ -17,6 +17,7 @@ import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { readDtTenders } from './dt-store.mjs';
|
||||
import { loginWithGoogle, userFromAuthHeader } from './auth.mjs';
|
||||
import { emailConfigured, sendEmail, tenderDigestHtml } from './email.mjs';
|
||||
|
||||
// ilan.gov.tr sunucusu ara sertifikayı (GeoTrust TLS RSA CA G1) göndermiyor;
|
||||
// zinciri tamamlamak için PEM'i yerelden ekliyoruz.
|
||||
@@ -336,6 +337,29 @@ const server = http.createServer(async (req, res) => {
|
||||
return json(res, 200, { success: true, user });
|
||||
}
|
||||
|
||||
// --- E-posta bildirimi (Resend) ---
|
||||
if (url.pathname === '/api/notify/email/config') {
|
||||
return json(res, 200, { configured: emailConfigured() });
|
||||
}
|
||||
// Giriş yapan kullanıcının KENDİ e-postasına test/özet gönderir (kötüye kullanımı önler).
|
||||
if (url.pathname === '/api/notify/email/test' && req.method === 'POST') {
|
||||
const user = userFromAuthHeader(req.headers['authorization']);
|
||||
if (!user) return json(res, 401, { success: false, error: 'oturum yok' });
|
||||
if (!emailConfigured()) return json(res, 503, { success: false, error: 'E-posta yapılandırılmamış (RESEND_API_KEY yok)' });
|
||||
try {
|
||||
const body = await readBody(req).catch(() => ({}));
|
||||
const html = tenderDigestHtml({ name: user.name || user.email, tenders: body.tenders || [] });
|
||||
const { id } = await sendEmail({
|
||||
to: user.email,
|
||||
subject: body.subject || 'İhaleist — bildirim testi',
|
||||
html,
|
||||
});
|
||||
return json(res, 200, { success: true, id, to: user.email });
|
||||
} catch (e) {
|
||||
return json(res, 502, { success: false, error: e.message });
|
||||
}
|
||||
}
|
||||
|
||||
if (url.pathname === '/api/tenders') {
|
||||
const force = url.searchParams.get('refresh') === '1';
|
||||
const c = await getTenders(force);
|
||||
|
||||
Reference in New Issue
Block a user