feat: add secure /api/admin/signups endpoint for abone takip
Quality gates / test-build (push) Canceled after 0s
Quality gates / container (push) Canceled after 0s

This commit is contained in:
2026-09-21 08:52:49 +03:00
parent 6fda6764c3
commit c68070ddf9
+27
View File
@@ -1034,6 +1034,33 @@ const server = http.createServer(async (req, res) => {
const [z, so] = await Promise.all([zeyilnameTara(), sonucTara()]); const [z, so] = await Promise.all([zeyilnameTara(), sonucTara()]);
return json(res, 200, { success: true, zeyilname: z, sonuc: so }); return json(res, 200, { success: true, zeyilname: z, sonuc: so });
} }
// --- Abone Takip Paneli Entegrasyonu (Signups & Subscribers) ---
if ((url.pathname === '/api/admin/signups' || url.pathname === '/api/admin/subscribers') && req.method === 'GET') {
const authHeader = req.headers['authorization'] || '';
const apiKeyHeader = req.headers['x-api-key'] || req.headers['x-webhook-secret'] || '';
const expectedKey = process.env.ABONE_TAKIP_SECRET || 'abone_takip_master_token_2026';
const token = authHeader.startsWith('Bearer ') ? authHeader.slice(7).trim() : apiKeyHeader.trim();
if (!token || (token !== expectedKey)) {
return json(res, 401, { success: false, error: 'Yetkisiz erişim' });
}
const users = store.withDb ? store.withDb((db) => db.prepare('SELECT email, ad, plan, olusturma, son_giris FROM kullanicilar').all(), []) : [];
const data = users.map(u => ({
email: u.email,
name: u.ad || null,
plan: u.plan || 'ucretsiz',
status: 'active',
is_paid: (u.plan && u.plan !== 'ucretsiz') ? 1 : 0,
payment_amount: (u.plan && u.plan !== 'ucretsiz') ? 499 : 0,
currency: 'TRY',
registered_at: u.olusturma || new Date().toISOString(),
last_login_at: u.son_giris || null
}));
return json(res, 200, { success: true, data });
}
if (url.pathname === '/api/health/kalem') { if (url.pathname === '/api/health/kalem') {
return json(res, 200, { success: true, ...kalemStore.kalemSayilari(), depo: kalemStore.available() }); return json(res, 200, { success: true, ...kalemStore.kalemSayilari(), depo: kalemStore.available() });
} }