DI2 внедрение, таск 1: серверная интеграция Data-Insight2 (server/finance-di2)
- Копия DI2-сервера в server/finance-di2/ с правками: schema/db-client/cache/table-config/override-tables/google-auth/audit-agent/routes - db-client — обёртка над существующим пулом server/finance/db-client (второй пул не создаётся, добавлен экспорт isConnectionError) - ai-config.ts — чистое IO конфигов из ai-agent.ts без Telegram-поллинга; роуты /api/ai/toggle и /api/ai/status удалены, без compression/startAuditScheduler/autoStartIfEnabled - Обёртка registerDi2Routes с auth-gate (authenticateToken + finance.manage), регистрация строго перед registerFinanceRoutes - Статика /di2 из dist/public-di2 перед веткой vite/static (dev и prod) - Фикс предсуществующего бага DI2: buildGlobalExclusionConditions без cats в /api/profitability
This commit is contained in:
@@ -125,3 +125,15 @@ export async function isConnected(): Promise<boolean> {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const CONNECTION_ERROR_CODES = new Set(["57P01", "57P02", "57P03", "08000", "08001", "08003", "08006"]);
|
||||
|
||||
export function isConnectionError(err: unknown): boolean {
|
||||
if (!(err instanceof Error)) return false;
|
||||
const code = (err as any).code;
|
||||
if (code && CONNECTION_ERROR_CODES.has(code)) return true;
|
||||
const msg = err.message.toLowerCase();
|
||||
return msg.includes("econnrefused") || msg.includes("etimedout") || msg.includes("enotfound") ||
|
||||
msg.includes("connection terminated") || msg.includes("connection timeout") ||
|
||||
msg.includes("закрытие подключения") || msg.includes("the database system is shutting down");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user