feat: Complete NestJS backend scaffold — 22 modules, 39 entities, WebSocket gateway
All checks were successful
Test Asgard Runner / test (push) Successful in 3s
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:
52
backend-nest/src/modules/status/status.service.ts
Normal file
52
backend-nest/src/modules/status/status.service.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { PublicSiteConfig } from '../../entities/public-site-config.entity';
|
||||
import { ServerConnection } from '../../entities/server-connection.entity';
|
||||
import { License } from '../../entities/license.entity';
|
||||
|
||||
@Injectable()
|
||||
export class StatusService {
|
||||
constructor(
|
||||
@InjectRepository(PublicSiteConfig)
|
||||
private readonly publicSiteRepo: Repository<PublicSiteConfig>,
|
||||
@InjectRepository(ServerConnection)
|
||||
private readonly serverConnectionRepo: Repository<ServerConnection>,
|
||||
@InjectRepository(License)
|
||||
private readonly licenseRepo: Repository<License>,
|
||||
) {}
|
||||
|
||||
async getStatus() {
|
||||
const publicConfigs = await this.publicSiteRepo.find({
|
||||
where: { show_on_status_page: true },
|
||||
relations: ['license'],
|
||||
});
|
||||
|
||||
const servers = await Promise.all(
|
||||
publicConfigs.map(async (config) => {
|
||||
const license = await this.licenseRepo.findOne({
|
||||
where: { id: config.license_id },
|
||||
});
|
||||
|
||||
const connection = await this.serverConnectionRepo.findOne({
|
||||
where: { license_id: config.license_id },
|
||||
});
|
||||
|
||||
return {
|
||||
server_name: license?.subdomain || 'Unknown Server',
|
||||
subdomain: license?.subdomain || null,
|
||||
status: connection?.connection_status || 'offline',
|
||||
player_count: 0, // Would need real-time data
|
||||
max_players: 0,
|
||||
steam_connect_url: config.steam_connect_url,
|
||||
motd: config.motd,
|
||||
discord_invite_url: config.discord_invite_url,
|
||||
theme_color: config.theme_color,
|
||||
description: config.status_page_description,
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
return { servers };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user