v0.3.3: fix db_size N/A + fix test-redis missing await
- db-status endpoint: fallback to config.dbPath when system_config db_path is empty
- test-redis endpoint: handler wasnt async, causing Promise serialization to {} instead of result
- Both endpoint handlers now properly async with await
This commit is contained in:
@@ -11,6 +11,7 @@ import { login, authMiddleware, verifyToken, changePassword } from '../admin/aut
|
|||||||
import { getStats } from '../admin/stats.service';
|
import { getStats } from '../admin/stats.service';
|
||||||
import { getAllSystemConfigs, updateSystemConfig, updateSystemConfigs, getSystemConfig } from '../admin/system-config.service';
|
import { getAllSystemConfigs, updateSystemConfig, updateSystemConfigs, getSystemConfig } from '../admin/system-config.service';
|
||||||
import { getDb } from '../database/database';
|
import { getDb } from '../database/database';
|
||||||
|
import config from '../config';
|
||||||
import { reconnectRedis, testRedisConnection } from '../middleware/cache';
|
import { reconnectRedis, testRedisConnection } from '../middleware/cache';
|
||||||
import { startQrLogin, getQrLoginStatus, cancelQrLogin } from '../cloud/qr-login.service';
|
import { startQrLogin, getQrLoginStatus, cancelQrLogin } from '../cloud/qr-login.service';
|
||||||
import { BaiduDriver } from '../cloud/drivers/baidu.driver';
|
import { BaiduDriver } from '../cloud/drivers/baidu.driver';
|
||||||
@@ -401,7 +402,7 @@ router.post('/admin/change-password', (req: Request, res: Response) => {
|
|||||||
/** GET /api/admin/db-status */
|
/** GET /api/admin/db-status */
|
||||||
router.get('/admin/db-status', async (_req: Request, res: Response) => {
|
router.get('/admin/db-status', async (_req: Request, res: Response) => {
|
||||||
try {
|
try {
|
||||||
const dbFile = getSystemConfig('db_path') || '';
|
const dbFile = getSystemConfig('db_path') || config.dbPath || '';
|
||||||
let dbSize = 'N/A';
|
let dbSize = 'N/A';
|
||||||
if (dbFile) {
|
if (dbFile) {
|
||||||
try {
|
try {
|
||||||
@@ -446,14 +447,14 @@ router.get('/admin/db-status', async (_req: Request, res: Response) => {
|
|||||||
// ═══════════════════════════════════════
|
// ═══════════════════════════════════════
|
||||||
|
|
||||||
/** POST /api/admin/test-redis */
|
/** POST /api/admin/test-redis */
|
||||||
router.post('/admin/test-redis', (req: Request, res: Response) => {
|
router.post('/admin/test-redis', async (req: Request, res: Response) => {
|
||||||
try {
|
try {
|
||||||
const { url } = req.body;
|
const { url } = req.body;
|
||||||
if (!url) {
|
if (!url) {
|
||||||
res.status(400).json({ ok: false, info: 'Redis URL is required' });
|
res.status(400).json({ ok: false, info: 'Redis URL is required' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const result = testRedisConnection(url);
|
const result = await testRedisConnection(url);
|
||||||
res.json(result);
|
res.json(result);
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
res.status(500).json({ ok: false, info: err.message || 'Redis test failed' });
|
res.status(500).json({ ok: false, info: err.message || 'Redis test failed' });
|
||||||
|
|||||||
Reference in New Issue
Block a user