Initial commit: BI Agentes platform
Independent dashboard for CambioReal agents with local SQLite auth and read-only RDS connection. Features login, per-agent transaction filtering, KPIs, charts (Chart.js), and detailed transaction table. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
26
src/db-local.js
Normal file
26
src/db-local.js
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* SQLite local — controle de agentes (auth + config)
|
||||
*/
|
||||
const Database = require('better-sqlite3');
|
||||
const path = require('path');
|
||||
|
||||
const DB_PATH = path.join(__dirname, '..', 'data', 'agentes.db');
|
||||
const db = new Database(DB_PATH);
|
||||
|
||||
// WAL mode for better concurrency
|
||||
db.pragma('journal_mode = WAL');
|
||||
|
||||
// Create tables
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS agentes (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
email TEXT UNIQUE NOT NULL,
|
||||
senha_hash TEXT NOT NULL,
|
||||
agente_id INTEGER NOT NULL,
|
||||
nome TEXT NOT NULL,
|
||||
ativo INTEGER DEFAULT 1,
|
||||
created_at TEXT DEFAULT (datetime('now'))
|
||||
)
|
||||
`);
|
||||
|
||||
module.exports = db;
|
||||
Reference in New Issue
Block a user