Refactor Bridge APIs, slim Bridge and reorder imports
Move and standardize API implementations under bridge/apis, slim down the Bridge class (remove inline action implementations, caches and large comment blocks) and relocate related types/exports. Clean up and reorder imports across many bridge/api modules, normalize constructors, add logger imports where needed, and adjust WebUI routing/import ordering. These changes centralize API logic, reduce Bridge surface area, and tidy module boundaries and imports.
This commit is contained in:
1 parent
a52a9724cb
commit
a49e507e15
22 files changed
+144
-452
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import { createLogger } from '@snowluma/common/logger';
|
||||
import { randomBytes, scryptSync, timingSafeEqual } from 'crypto';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { createLogger } from '@snowluma/common/logger';
|
||||
|
||||
const log = createLogger('WebUI.Auth');
|
||||
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
import net from 'net';
|
||||
|
||||
/**
|
||||
* Probe whether a TCP port is bindable on the given host.
|
||||
* Resolves to true when bind+listen succeed.
|
||||
*/
|
||||
function isPortAvailable(port: number, host = '0.0.0.0'): Promise<boolean> {
|
||||
return new Promise((resolve) => {
|
||||
const server = net.createServer();
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import { serve } from '@hono/node-server';
|
||||
import { serveStatic } from '@hono/node-server/serve-static';
|
||||
import { Hono, type Context } from 'hono';
|
||||
import { describeTrustProxy, makeClientIpResolver, parseTrustProxy } from './client-ip';
|
||||
import { createLogger, getLogLevel, getRecentLogs, LOG_LEVELS, setLogLevel, subscribeLogs } from '@snowluma/common/logger';
|
||||
import { randomBytes } from 'crypto';
|
||||
import type { OneBotManager } from '@snowluma/onebot/manager';
|
||||
import { loadOneBotConfig, saveOneBotConfig } from '@snowluma/onebot/config';
|
||||
import type { OneBotConfig } from '@snowluma/onebot/types';
|
||||
import type { HookManager, HookProcessInfo } from '@snowluma/bridge';
|
||||
import path from 'path';
|
||||
import { createLogger, getLogLevel, getRecentLogs, LOG_LEVELS, setLogLevel, subscribeLogs } from '@snowluma/common/logger';
|
||||
import { loadOneBotConfig, saveOneBotConfig } from '@snowluma/onebot/config';
|
||||
import type { OneBotManager } from '@snowluma/onebot/manager';
|
||||
import type { OneBotConfig } from '@snowluma/onebot/types';
|
||||
import { randomBytes } from 'crypto';
|
||||
import { existsSync, readFileSync } from 'fs';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { Hono, type Context } from 'hono';
|
||||
import os from 'os';
|
||||
import { WebuiAuth, evaluatePasswordRules, isStrongPassword } from './auth';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { evaluatePasswordRules, isStrongPassword, WebuiAuth } from './auth';
|
||||
import { describeTrustProxy, makeClientIpResolver, parseTrustProxy } from './client-ip';
|
||||
import { findAvailablePort } from './port';
|
||||
|
||||
const log = createLogger('WebUI');
|
||||
@@ -446,8 +446,8 @@ export async function initWebUI(
|
||||
}
|
||||
};
|
||||
}
|
||||
app.post('/api/processes/:pid/load', processAction('load', (pid) => hookManager!.loadProcess(pid)));
|
||||
app.post('/api/processes/:pid/unload', processAction('unload', (pid) => hookManager!.unloadProcess(pid)));
|
||||
app.post('/api/processes/:pid/load', processAction('load', (pid) => hookManager!.loadProcess(pid)));
|
||||
app.post('/api/processes/:pid/unload', processAction('unload', (pid) => hookManager!.unloadProcess(pid)));
|
||||
app.post('/api/processes/:pid/refresh', processAction('refresh', (pid) => hookManager!.refreshProcess(pid)));
|
||||
|
||||
app.get('/api/processes/:pid/probe-login', async (c) => {
|
||||
|
||||
Reference in new issue
Block a user