mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-13 04:06:59 +00:00
refactor(backend): extract auto-heal, notifications, console, sso-config routers (phase 4c-1) (#739)
Move four small Round C route groups out of index.ts: - /api/auto-heal/* -> routes/autoHeal.ts - /api/notifications/*, /api/notification-routes/* -> routes/notifications.ts - /api/system/console-token -> routes/console.ts - /api/sso/config/* -> routes/ssoConfig.ts Share NOTIFICATION_CHANNEL_TYPES, cleanStackPatterns, and validateHttpsUrl via a new helpers/notificationChannels.ts so agents.ts and notifications.ts consume the same allowlist and URL validator. Handlers moved verbatim. Middleware chains and response shapes preserved. index.ts drops from 3231 to 2739 lines.
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
export const NOTIFICATION_CHANNEL_TYPES = ['discord', 'slack', 'webhook'] as const;
|
||||
export type NotificationChannelType = typeof NOTIFICATION_CHANNEL_TYPES[number];
|
||||
|
||||
export const cleanStackPatterns = (patterns: string[]): string[] =>
|
||||
[...new Set(patterns.map(p => p.trim()).filter(Boolean))];
|
||||
|
||||
export function validateHttpsUrl(value: unknown): string | null {
|
||||
if (!value || typeof value !== 'string' || !value.startsWith('https://')) return 'must be a valid HTTPS URL';
|
||||
try { new URL(value); } catch { return 'is not a valid URL'; }
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user