deploy: canlı veri backend'ini container'a ekle (nginx /api → Node :3001)

- Dockerfile: nginx + Node tek container; backend arka planda, nginx ön planda
- nginx.conf: /api → 127.0.0.1:3001 proxy
- dt-store: node:sqlite guard (yoksa DT devre dışı, açık ihaleler yine canlı)
- Açık ihale canlı verisi sıfır npm bağımlılığıyla deploy'da çalışır
This commit is contained in:
2026-08-26 21:28:25 +03:00
parent 89cfd03d92
commit 4f1ba88e94
3 changed files with 39 additions and 10 deletions
+10 -2
View File
@@ -3,11 +3,19 @@
* Veritabanı yoksa (worker hiç koşmadıysa) sessizce boş liste döner.
*/
import { DatabaseSync } from 'node:sqlite';
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
// node:sqlite bazı Node sürümlerinde deneysel/flag'li. Yoksa DT devre dışı kalır,
// ilan.gov.tr canlı verisi yine de çalışır.
let DatabaseSync = null;
try {
({ DatabaseSync } = await import('node:sqlite'));
} catch {
console.warn('[dt-store] node:sqlite yok — doğrudan temin devre dışı (açık ihaleler etkilenmez)');
}
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const DB_PATH = path.join(__dirname, 'data', 'dt.sqlite');
@@ -92,7 +100,7 @@ function mapDtRow(row) {
}
export function readDtTenders(limit = 300) {
if (!fs.existsSync(DB_PATH)) return { tenders: [], totalCount: 0, available: false };
if (!DatabaseSync || !fs.existsSync(DB_PATH)) return { tenders: [], totalCount: 0, available: false };
const db = new DatabaseSync(DB_PATH, { readOnly: true });
try {
const total = db.prepare('SELECT COUNT(*) c FROM dt_tenders').get().c;