mirror of
https://github.com/UNITRONIX/BetterDesk.git
synced 2026-09-10 17:45:42 +00:00
00451634c7
Convert many Express route handlers and helper functions to async and await database calls (e.g. getAccessToken, touchAccessToken, getPeerById, getDevice, getPeerSysinfo, upsertPeerSysinfo, logAction, insertAudit*, getAll*/count* etc.). Also made identifyDevice and several route callbacks async, adjusted session.regenerate callback to use async logging, and replaced db.getDatabase() usage with db.getDb() where applicable. These changes ensure DB operations complete before responding and reduce race conditions/unhandled-promise behavior across numerous route files (activity, auth, automation, bd-api, devices, folders, i18n, inventory, registration, remote, rustdesk-api, and related route handlers). Co-Authored-By: Charles Olivier Savignac <1275666+sircharlo@users.noreply.github.com>
35 lines
1.1 KiB
JavaScript
35 lines
1.1 KiB
JavaScript
const config = require('./config/config');
|
|
const db = require('./services/database');
|
|
|
|
console.log('Config:');
|
|
console.log(' DB_PATH:', config.dbPath);
|
|
console.log(' DATA_DIR:', config.dataDir);
|
|
console.log(' KEYS_PATH:', config.keysPath);
|
|
console.log(' DB_TYPE:', db.DB_TYPE || 'sqlite');
|
|
console.log('');
|
|
|
|
(async () => {
|
|
try {
|
|
await db.init();
|
|
|
|
const devices = await db.getAllDevices({});
|
|
console.log('Total devices:', devices.length);
|
|
console.log('Type:', typeof devices);
|
|
console.log('Is array:', Array.isArray(devices));
|
|
if (devices.length > 0) {
|
|
console.log('First device:', JSON.stringify(devices[0], null, 2));
|
|
}
|
|
|
|
const stats = await db.getStats();
|
|
console.log('Stats:', JSON.stringify(stats, null, 2));
|
|
|
|
const auditLogs = await db.getAuditLogs(5);
|
|
console.log('Audit logs:', JSON.stringify(auditLogs, null, 2));
|
|
} catch (err) {
|
|
console.error('Error:', err.message);
|
|
console.error('Stack:', err.stack);
|
|
} finally {
|
|
await db.close();
|
|
}
|
|
})();
|