feat: Complete NestJS backend scaffold — 22 modules, 39 entities, WebSocket gateway
All checks were successful
Test Asgard Runner / test (push) Successful in 3s

Full backend rewrite from Rust/Axum to NestJS/TypeScript.
- 22 feature modules (auth, servers, wipes, maps, plugins, players, console,
  chat, team, notifications, settings, schedules, analytics, alerts, status,
  store, webstore, admin, setup, migration, users, licenses)
- 39 TypeORM entities matching PostgreSQL schema (12 migrations)
- Common infrastructure: JWT/RBAC guards, decorators, exception filter
- NATS service with pub/sub/request-reply
- Socket.IO WebSocket gateway with NATS bridge
- Docker: NestJS Dockerfile + updated docker-compose.yml
- Zero compile errors (npx tsc --noEmit clean)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Vantz Stockwell
2026-02-15 21:29:25 -05:00
parent 0f8d0dd14f
commit d20493d533
141 changed files with 13552 additions and 4 deletions

View File

@@ -0,0 +1,38 @@
import { Controller, Get, Put, Body, Query } from '@nestjs/common';
import { ApiTags, ApiBearerAuth, ApiOperation, ApiQuery } from '@nestjs/swagger';
import { AlertsService } from './alerts.service';
import { UpdateAlertConfigDto } from './dto/update-alert-config.dto';
import { CurrentTenant } from '../../common/decorators/current-tenant.decorator';
@ApiTags('alerts')
@ApiBearerAuth()
@Controller('alerts')
export class AlertsController {
constructor(private readonly alertsService: AlertsService) {}
@Get('config')
@ApiOperation({ summary: 'Get alert configuration' })
async getConfig(@CurrentTenant() licenseId: string) {
return this.alertsService.getConfig(licenseId);
}
@Put('config')
@ApiOperation({ summary: 'Update alert configuration' })
async updateConfig(
@CurrentTenant() licenseId: string,
@Body() dto: UpdateAlertConfigDto,
) {
return this.alertsService.updateConfig(licenseId, dto);
}
@Get('history')
@ApiOperation({ summary: 'Get alert history' })
@ApiQuery({ name: 'limit', required: false, type: Number, description: 'Max records to return (default: 50)' })
async getHistory(
@CurrentTenant() licenseId: string,
@Query('limit') limit?: string,
) {
const limitNum = limit ? parseInt(limit, 10) : 50;
return this.alertsService.getHistory(licenseId, limitNum);
}
}

View File

@@ -0,0 +1,14 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { AlertsController } from './alerts.controller';
import { AlertsService } from './alerts.service';
import { AlertConfig } from '../../entities/alert-config.entity';
import { AlertHistory } from '../../entities/alert-history.entity';
@Module({
imports: [TypeOrmModule.forFeature([AlertConfig, AlertHistory])],
controllers: [AlertsController],
providers: [AlertsService],
exports: [AlertsService],
})
export class AlertsModule {}

View File

@@ -0,0 +1,65 @@
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { AlertConfig } from '../../entities/alert-config.entity';
import { AlertHistory } from '../../entities/alert-history.entity';
import { UpdateAlertConfigDto } from './dto/update-alert-config.dto';
@Injectable()
export class AlertsService {
constructor(
@InjectRepository(AlertConfig)
private readonly alertConfigRepo: Repository<AlertConfig>,
@InjectRepository(AlertHistory)
private readonly alertHistoryRepo: Repository<AlertHistory>,
) {}
async getConfig(licenseId: string): Promise<AlertConfig> {
let config = await this.alertConfigRepo.findOne({
where: { license_id: licenseId },
});
if (!config) {
// Create default config if not exists
config = this.alertConfigRepo.create({
license_id: licenseId,
population_drop_enabled: true,
population_drop_threshold_percent: 30,
fps_degradation_enabled: true,
fps_threshold: 30,
notify_discord: true,
notify_pushbullet: false,
notify_email: false,
});
await this.alertConfigRepo.save(config);
}
return config;
}
async updateConfig(licenseId: string, dto: UpdateAlertConfigDto): Promise<AlertConfig> {
let config = await this.alertConfigRepo.findOne({
where: { license_id: licenseId },
});
if (!config) {
config = this.alertConfigRepo.create({
license_id: licenseId,
...dto,
});
} else {
Object.assign(config, dto);
config.updated_at = new Date();
}
return this.alertConfigRepo.save(config);
}
async getHistory(licenseId: string, limit: number = 50): Promise<AlertHistory[]> {
return this.alertHistoryRepo.find({
where: { license_id: licenseId },
order: { triggered_at: 'DESC' },
take: limit,
});
}
}

View File

@@ -0,0 +1,42 @@
import { IsBoolean, IsInt, IsOptional, Min, Max } from 'class-validator';
import { ApiPropertyOptional } from '@nestjs/swagger';
export class UpdateAlertConfigDto {
@ApiPropertyOptional({ description: 'Enable population drop alerts' })
@IsOptional()
@IsBoolean()
population_drop_enabled?: boolean;
@ApiPropertyOptional({ description: 'Population drop threshold percentage' })
@IsOptional()
@IsInt()
@Min(1)
@Max(100)
population_drop_threshold_percent?: number;
@ApiPropertyOptional({ description: 'Enable FPS degradation alerts' })
@IsOptional()
@IsBoolean()
fps_degradation_enabled?: boolean;
@ApiPropertyOptional({ description: 'FPS threshold for alerts' })
@IsOptional()
@IsInt()
@Min(1)
fps_threshold?: number;
@ApiPropertyOptional({ description: 'Send alerts to Discord' })
@IsOptional()
@IsBoolean()
notify_discord?: boolean;
@ApiPropertyOptional({ description: 'Send alerts to Pushbullet' })
@IsOptional()
@IsBoolean()
notify_pushbullet?: boolean;
@ApiPropertyOptional({ description: 'Send alerts via email' })
@IsOptional()
@IsBoolean()
notify_email?: boolean;
}