feat: RLA API v1.0.0 — API complète + exports + thème McKinsey
- 9 endpoints métier : synthese, alertes, en-service, en-cours, par-region, clotures, pilotage-proactif, matrice-risque - Exports PDF (tous rôles) / XLSX PPTX DOCX (superadmin) - services/calc.js : helpers normalisés partagés - services/export-pdf.js : PDF async PDFKit par vue - Thème McKinsey (#1C2B4B / bleu pétrole / gris sobre) - Boutons XLSX/DOCX front (superadmin uniquement) - BASEROW_API_URL → https://baserow.bolbol.tn/api/ - dotenv override: true Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const LOGS_FILE = path.join(__dirname, '..', 'logs', 'connexions.json');
|
||||
const MAX_LOGS = 500;
|
||||
|
||||
function readLogs() {
|
||||
try {
|
||||
return JSON.parse(fs.readFileSync(LOGS_FILE, 'utf8'));
|
||||
} catch (_) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
function writeLogs(logs) {
|
||||
fs.mkdirSync(path.dirname(LOGS_FILE), { recursive: true });
|
||||
fs.writeFileSync(LOGS_FILE, JSON.stringify(logs, null, 2), 'utf8');
|
||||
}
|
||||
|
||||
function logLogin({ username, role = null, ip = null, success }) {
|
||||
const logs = readLogs();
|
||||
logs.unshift({ timestamp: new Date().toISOString(), username, role, ip, success: !!success });
|
||||
if (logs.length > MAX_LOGS) logs.length = MAX_LOGS;
|
||||
writeLogs(logs);
|
||||
}
|
||||
|
||||
function getLogs(limit = 100) {
|
||||
return readLogs().slice(0, limit);
|
||||
}
|
||||
|
||||
module.exports = { logLogin, getLogs };
|
||||
Reference in New Issue
Block a user