forked from DigiNodes/truthbounty-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.controller.ts
More file actions
163 lines (145 loc) · 6.85 KB
/
Copy pathdashboard.controller.ts
File metadata and controls
163 lines (145 loc) · 6.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import { Controller, Get, Query, UseGuards } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiResponse, ApiBearerAuth, ApiQuery } from '@nestjs/swagger';
import { DashboardService } from './dashboard.service';
import { AdminGuard } from '../guards/admin.guard';
import { RolesGuard } from '../guards/roles.guard';
import { Roles } from '../decorators/roles.decorator';
import { AdminRole } from '../entities/admin.entity';
import {
DashboardOverviewDto,
HealthStatusDto,
OperationalDashboardDto,
InfrastructureHealthDto,
QueueMetricsDto,
WorkerStatusDto,
ApiMetricsDto,
CacheStatisticsDto,
DatabaseMetricsDto,
NotificationMetricsDto,
WebhookMetricsDto,
BackgroundJobsDto,
ProtocolActivityDto,
} from '../dto/dashboard.dto';
@ApiTags('admin / dashboard')
@ApiBearerAuth()
@Controller('admin/dashboard')
@UseGuards(AdminGuard, RolesGuard)
export class DashboardController {
constructor(private readonly dashboardService: DashboardService) {}
@Get('overview')
@Roles(AdminRole.SUPER_ADMIN, AdminRole.ADMINISTRATOR, AdminRole.AUDITOR)
@ApiOperation({ summary: 'Get main dashboard overview' })
@ApiResponse({ status: 200, description: 'Dashboard overview data', type: DashboardOverviewDto })
async getOverview() {
return this.dashboardService.getOverview();
}
@Get('health')
@Roles(AdminRole.SUPER_ADMIN, AdminRole.ADMINISTRATOR, AdminRole.SECURITY_ANALYST, AdminRole.AUDITOR)
@ApiOperation({ summary: 'Get protocol health status' })
@ApiResponse({ status: 200, description: 'System health summary', type: HealthStatusDto })
async getHealth() {
return this.dashboardService.getHealth();
}
@Get('operational-summary')
@Roles(AdminRole.SUPER_ADMIN, AdminRole.ADMINISTRATOR, AdminRole.AUDITOR, AdminRole.SECURITY_ANALYST)
@ApiOperation({ summary: 'Get aggregated operational dashboard summary' })
@ApiResponse({ status: 200, description: 'Aggregated operational dashboard data', type: OperationalDashboardDto })
async getOperationalSummary() {
return this.dashboardService.getOperationalSummary();
}
@Get('infrastructure')
@Roles(AdminRole.SUPER_ADMIN, AdminRole.ADMINISTRATOR, AdminRole.AUDITOR, AdminRole.SECURITY_ANALYST)
@ApiOperation({ summary: 'Get infrastructure health and queue status' })
@ApiResponse({ status: 200, description: 'Infrastructure health summary', type: InfrastructureHealthDto })
async getInfrastructureHealth() {
return this.dashboardService.getInfrastructureHealth();
}
@Get('queues')
@Roles(AdminRole.SUPER_ADMIN, AdminRole.ADMINISTRATOR, AdminRole.AUDITOR, AdminRole.SECURITY_ANALYST)
@ApiOperation({ summary: 'Get queue statistics across background workers' })
@ApiResponse({ status: 200, description: 'Queue metrics', type: QueueMetricsDto })
async getQueueStatistics() {
return this.dashboardService.getQueueStatistics();
}
@Get('workers')
@Roles(AdminRole.SUPER_ADMIN, AdminRole.ADMINISTRATOR, AdminRole.AUDITOR, AdminRole.SECURITY_ANALYST)
@ApiOperation({ summary: 'Get worker health and utilisation' })
@ApiResponse({ status: 200, description: 'Worker status summary', type: WorkerStatusDto })
async getWorkerStatus() {
return this.dashboardService.getWorkerStatus();
}
@Get('api-metrics')
@Roles(AdminRole.SUPER_ADMIN, AdminRole.ADMINISTRATOR, AdminRole.AUDITOR, AdminRole.SECURITY_ANALYST)
@ApiOperation({ summary: 'Get API traffic and latency metrics' })
@ApiResponse({ status: 200, description: 'API metrics summary', type: ApiMetricsDto })
async getApiMetrics() {
return this.dashboardService.getApiMetrics();
}
@Get('cache')
@Roles(AdminRole.SUPER_ADMIN, AdminRole.ADMINISTRATOR, AdminRole.AUDITOR, AdminRole.SECURITY_ANALYST)
@ApiOperation({ summary: 'Get cache and Redis status' })
@ApiResponse({ status: 200, description: 'Cache summary', type: CacheStatisticsDto })
async getCacheStatistics() {
return this.dashboardService.getCacheStatistics();
}
@Get('database')
@Roles(AdminRole.SUPER_ADMIN, AdminRole.ADMINISTRATOR, AdminRole.AUDITOR, AdminRole.SECURITY_ANALYST)
@ApiOperation({ summary: 'Get database health and table statistics' })
@ApiResponse({ status: 200, description: 'Database metrics', type: DatabaseMetricsDto })
async getDatabaseMetrics() {
return this.dashboardService.getDatabaseMetrics();
}
@Get('notifications')
@Roles(AdminRole.SUPER_ADMIN, AdminRole.ADMINISTRATOR, AdminRole.AUDITOR, AdminRole.SECURITY_ANALYST)
@ApiOperation({ summary: 'Get notification queue and delivery metrics' })
@ApiResponse({ status: 200, description: 'Notification metrics', type: NotificationMetricsDto })
async getNotificationMetrics() {
return this.dashboardService.getNotificationMetrics();
}
@Get('webhooks')
@Roles(AdminRole.SUPER_ADMIN, AdminRole.ADMINISTRATOR, AdminRole.AUDITOR, AdminRole.SECURITY_ANALYST)
@ApiOperation({ summary: 'Get webhook delivery metrics' })
@ApiResponse({ status: 200, description: 'Webhook metrics', type: WebhookMetricsDto })
async getWebhookMetrics() {
return this.dashboardService.getWebhookMetrics();
}
@Get('jobs')
@Roles(AdminRole.SUPER_ADMIN, AdminRole.ADMINISTRATOR, AdminRole.AUDITOR, AdminRole.SECURITY_ANALYST)
@ApiOperation({ summary: 'Get background job queue overview' })
@ApiResponse({ status: 200, description: 'Background job overview', type: BackgroundJobsDto })
async getBackgroundJobs() {
return this.dashboardService.getBackgroundJobs();
}
@Get('protocol')
@Roles(AdminRole.SUPER_ADMIN, AdminRole.ADMINISTRATOR, AdminRole.AUDITOR, AdminRole.SECURITY_ANALYST)
@ApiOperation({ summary: 'Get protocol activity summary' })
@ApiResponse({ status: 200, description: 'Protocol activity summary', type: ProtocolActivityDto })
async getProtocolActivity() {
return this.dashboardService.getProtocolActivity();
}
@Get('moderation')
@Roles(AdminRole.SUPER_ADMIN, AdminRole.ADMINISTRATOR, AdminRole.MODERATOR, AdminRole.AUDITOR)
@ApiOperation({ summary: 'Get moderation workload statistics' })
async getModerationStats() {
return this.dashboardService.getOverview();
}
@Get('incidents')
@Roles(AdminRole.SUPER_ADMIN, AdminRole.ADMINISTRATOR, AdminRole.SECURITY_ANALYST, AdminRole.AUDITOR)
@ApiOperation({ summary: 'Get incident statistics' })
async getIncidentStats() {
return this.dashboardService.getOverview();
}
@Get('audit')
@Roles(AdminRole.SUPER_ADMIN, AdminRole.ADMINISTRATOR, AdminRole.AUDITOR)
@ApiOperation({ summary: 'Get audit summary' })
@ApiQuery({ name: 'days', required: false, description: 'Number of days' })
async getAuditSummary(@Query('days') days?: string) {
return this.dashboardService.getAuditSummary(days ? parseInt(days, 10) : 7);
}
@Get('monitoring')
@Roles(AdminRole.SUPER_ADMIN, AdminRole.ADMINISTRATOR, AdminRole.SECURITY_ANALYST, AdminRole.AUDITOR)
@ApiOperation({ summary: 'Get real-time monitoring metrics' })
async getMonitoring() {
return this.dashboardService.getMonitoring();
}
}