Files
InvestPlay/apps/api/src/app.controller.ts
Lefteris Notas e75f913f1c
Some checks failed
CI / Lint (push) Has been cancelled
CI / TypeCheck (push) Has been cancelled
CI / Test (push) Has been cancelled
Deploy / Docker Build & Push (map[context:. dockerfile:apps/api/Dockerfile name:api]) (push) Has been cancelled
Deploy / Docker Build & Push (map[context:. dockerfile:apps/cms/Dockerfile name:cms]) (push) Has been cancelled
Deploy / Docker Build & Push (map[context:. dockerfile:apps/web/Dockerfile name:web]) (push) Has been cancelled
CI / Build (push) Has been cancelled
Deploy / Deploy (push) Has been cancelled
feat: complete Phase 1 foundation scaffold
- Monorepo: Turborepo + pnpm workspaces with 7 apps/packages
- Backend: NestJS scaffold with 9 modules (auth, tenant, curriculum, simulation, portfolio, ai-coach, analytics, classroom, gamification)
- Frontend: React 18 + Vite + TailwindCSS + shadcn/ui with 10 pages, 14 UI primitives, 3 Zustand stores
- Database: Prisma schema with 19 models, 13 enums, seed script, multi-tenant ready
- Docker: Dev, production, and Portainer Compose files with Traefik reverse proxy
- Configuration: .env.example (47 vars), Zod validation, frontend-safe env exposure
- i18n: English + Greek locale files (10 files), ICU MessageFormat, react-i18next
- Shared packages: @investplay/types, @investplay/ui, @investplay/i18n, @investplay/utils
- CI/CD: GitHub Actions (lint, typecheck, test, build, deploy, PR checks)
- Documentation: CONTEXT.md, ARCHITECTURE.md (10 Mermaid diagrams), API.md, LOCALIZATION.md, DEVELOPMENT-ROADMAP.md
- Infrastructure: Dockerfiles (dev + prod), nginx configs, backup/healthcheck scripts
- Security: JWT auth guards, role-based access, rate limiting, Helmet, CORS, PII sanitization
2026-06-12 19:32:57 +03:00

64 lines
1.7 KiB
TypeScript

import { Controller, Get, Logger, ServiceUnavailableException } from "@nestjs/common";
import { SkipThrottle } from "@nestjs/throttler";
import { Public } from "./common/decorators/public.decorator.js";
import { PrismaService } from "./common/prisma/prisma.service.js";
import { RedisService } from "./common/redis/redis.service.js";
@SkipThrottle()
@Controller("health")
export class AppController {
private readonly logger = new Logger(AppController.name);
private readonly startTime: number;
constructor(
private readonly prisma: PrismaService,
private readonly redis: RedisService,
) {
this.startTime = Date.now();
}
@Public()
@Get()
check() {
return {
status: "ok",
timestamp: new Date().toISOString(),
version: process.env.npm_package_version ?? "0.1.0",
uptime: Math.floor((Date.now() - this.startTime) / 1000),
environment: process.env.NODE_ENV ?? "development",
};
}
@Public()
@Get("db")
async checkDatabase() {
try {
await this.prisma.$queryRaw`SELECT 1`;
return { status: "ok", service: "database" };
} catch (error) {
this.logger.error("Database health check failed", error);
throw new ServiceUnavailableException({
status: "error",
service: "database",
message: "Database connection failed",
});
}
}
@Public()
@Get("redis")
async checkRedis() {
try {
await this.redis.ping();
return { status: "ok", service: "redis" };
} catch (error) {
this.logger.error("Redis health check failed", error);
throw new ServiceUnavailableException({
status: "error",
service: "redis",
message: "Redis connection failed",
});
}
}
}