100 lines
2.1 KiB
TypeScript
100 lines
2.1 KiB
TypeScript
import apiClient from './api/client'
|
|
|
|
export interface HealthStatus {
|
|
status: 'healthy' | 'degraded' | 'down'
|
|
database: 'connected' | 'disconnected'
|
|
redis: 'connected' | 'disconnected'
|
|
uptime: number
|
|
timestamp: string
|
|
recentErrors?: number
|
|
activeUsers?: number
|
|
}
|
|
|
|
export interface SystemInfo {
|
|
version: string
|
|
environment: string
|
|
nodeVersion: string
|
|
memory: {
|
|
used: number
|
|
total: number
|
|
}
|
|
cpu: {
|
|
usage: number
|
|
cores: number
|
|
loadAverage?: number[]
|
|
}
|
|
platform?: string
|
|
architecture?: string
|
|
uptime?: number
|
|
env?: string
|
|
}
|
|
|
|
export interface MaintenanceStatus {
|
|
id: string
|
|
status: 'ACTIVE' | 'INACTIVE'
|
|
message?: string
|
|
scheduledAt?: string | null
|
|
startedAt?: string | null
|
|
endedAt?: string | null
|
|
enabledBy?: string
|
|
createdAt: string
|
|
updatedAt: string
|
|
}
|
|
|
|
class SystemService {
|
|
/**
|
|
* Get system health status
|
|
*/
|
|
async getHealth(): Promise<HealthStatus> {
|
|
const response = await apiClient.get<HealthStatus>('/admin/system/health')
|
|
return response.data
|
|
}
|
|
|
|
/**
|
|
* Get system information
|
|
*/
|
|
async getSystemInfo(): Promise<SystemInfo> {
|
|
const response = await apiClient.get<SystemInfo>('/admin/system/info')
|
|
return response.data
|
|
}
|
|
|
|
/**
|
|
* Get maintenance mode status
|
|
*/
|
|
async getMaintenanceStatus(): Promise<MaintenanceStatus> {
|
|
const response = await apiClient.get<MaintenanceStatus>('/admin/maintenance')
|
|
return response.data
|
|
}
|
|
|
|
/**
|
|
* Enable maintenance mode
|
|
*/
|
|
async enableMaintenance(message?: string): Promise<void> {
|
|
await apiClient.post('/admin/maintenance/enable', { message })
|
|
}
|
|
|
|
/**
|
|
* Disable maintenance mode
|
|
*/
|
|
async disableMaintenance(): Promise<void> {
|
|
await apiClient.post('/admin/maintenance/disable')
|
|
}
|
|
|
|
/**
|
|
* Clear application cache
|
|
*/
|
|
async clearCache(): Promise<void> {
|
|
await apiClient.post('/admin/system/clear-cache')
|
|
}
|
|
|
|
/**
|
|
* Run database migrations
|
|
*/
|
|
async runMigrations(): Promise<{ success: boolean; message: string }> {
|
|
const response = await apiClient.post('/admin/system/migrate')
|
|
return response.data
|
|
}
|
|
}
|
|
|
|
export const systemService = new SystemService()
|