Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { Controller, Get, VERSION_NEUTRAL, Version } from '@nestjs/common';
import { Controller, Get, HttpStatus,VERSION_NEUTRAL, Version, ApiResponse, ApiTags } from '@nestjs/common';

Check warning on line 1 in src/app.controller.ts

View workflow job for this annotation

GitHub Actions / ESLint

'Version' is defined but never used. Allowed unused vars must match /^_/u

Check warning on line 1 in src/app.controller.ts

View workflow job for this annotation

GitHub Actions / ESLint

'VERSION_NEUTRAL' is defined but never used. Allowed unused vars must match /^_/u

Check failure on line 1 in src/app.controller.ts

View workflow job for this annotation

GitHub Actions / ESLint

Replace `·Controller,·Get,·HttpStatus,VERSION_NEUTRAL,·Version,·ApiResponse,·ApiTags·` with `⏎··Controller,⏎··Get,⏎··HttpStatus,⏎··VERSION_NEUTRAL,⏎··Version,⏎··ApiResponse,⏎··ApiTags,⏎`
import { AppService } from './app.service';

@Version(VERSION_NEUTRAL)
@ApiTags('app')
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}

@Get()
@ApiResponse({ status: HttpStatus.OK, description: 'Root endpoint response' })
getHello(): string {
return this.appService.getHello();
}
Expand Down
12 changes: 12 additions & 0 deletions src/backup/backup.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ import {
ParseUUIDPipe,
HttpCode,
HttpStatus,
UseGuards,
ApiResponse,
} from '@nestjs/common';
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
import { RecoveryTestingService } from './testing/recovery-testing.service';
import { DisasterRecoveryService } from './disaster-recovery/disaster-recovery.service';
import { BackupMonitoringService } from './monitoring/backup-monitoring.service';
Expand All @@ -18,6 +21,7 @@ import { RecoveryTestResponseDto } from './dto/recovery-test-response.dto';

@ApiTags('backup')
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Controller('backup')
export class BackupController {
constructor(
Expand All @@ -28,6 +32,7 @@ export class BackupController {

@Post('restore')
@ApiOperation({ summary: 'Restore from backup' })
@ApiResponse({ status: HttpStatus.ACCEPTED, description: 'Restore initiated' })
@HttpCode(HttpStatus.ACCEPTED)
async restoreBackup(@Body() dto: RestoreBackupDto): Promise<{ message: string }> {
await this.disasterRecoveryService.executeRestore(dto.backupRecordId);
Expand All @@ -36,12 +41,18 @@ export class BackupController {

@Post('test')
@ApiOperation({ summary: 'Trigger recovery test' })
@ApiResponse({ status: HttpStatus.OK, description: 'Recovery test triggered' })
async triggerRecoveryTest(@Body() dto: TriggerRecoveryTestDto): Promise<RecoveryTestResponseDto> {
return this.recoveryTestingService.createRecoveryTest(dto.backupRecordId);
}

@Get('test/:testId')
@ApiOperation({ summary: 'Get recovery test results' })
@ApiResponse({
status: HttpStatus.OK,
description: 'Recovery test results',
type: RecoveryTestResponseDto,
})
async getRecoveryTest(
@Param('testId', ParseUUIDPipe) testId: string,
): Promise<RecoveryTestResponseDto> {
Expand All @@ -50,6 +61,7 @@ export class BackupController {

@Get('health')
@ApiOperation({ summary: 'Get backup system health' })
@ApiResponse({ status: HttpStatus.OK, description: 'Backup health status' })
async getBackupHealth(): Promise<{ healthy: boolean; issues: string[] }> {
return this.backupMonitoringService.checkBackupHealth();
}
Expand Down
23 changes: 22 additions & 1 deletion src/health/health.controller.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
import { Controller, Get, VERSION_NEUTRAL, Version } from '@nestjs/common';
import {
Controller,
Get,
HttpStatus,
ApiResponse,
ApiTags,
ApiBearerAuth,
UseGuards,VERSION_NEUTRAL,
Version
} from '@nestjs/common';
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
import { DataSource } from 'typeorm';
import Redis from 'ioredis';
import { SkipThrottle } from '@nestjs/throttler';
import { HealthService } from './health.service';
import { HealthStatus } from './health.service';

@Version(VERSION_NEUTRAL)
@SkipThrottle()
@ApiTags('health')
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Controller('health')
export class HealthController {
private redis: Redis;
Expand All @@ -25,17 +39,24 @@ export class HealthController {
}

@Get()
@ApiResponse({ status: HttpStatus.OK, description: 'Health check response', type: HealthStatus })
async checkHealth() {
const healthStatus = await this.healthService.checkHealth(this.dataSource, this.redis);
return healthStatus;
}

@Get('liveness')
@ApiResponse({ status: HttpStatus.OK, description: 'Liveness check response' })
async checkLiveness() {
return { status: 'ok', timestamp: new Date().toISOString() };
}

@Get('readiness')
@ApiResponse({
status: HttpStatus.OK,
description: 'Readiness check response',
type: HealthStatus,
})
async checkReadiness() {
const healthStatus = await this.healthService.checkReadiness(this.dataSource, this.redis);
return healthStatus;
Expand Down
Loading