Establishes multi-tenant database layer with vector similarity search for AI-powered memory features. Includes Docker infrastructure, Prisma ORM integration, NestJS services, and shared types across the monorepo. Key changes: - Docker: PostgreSQL 17 + pgvector v0.7.4, Valkey cache - Schema: 8 models (User, Workspace, Task, Event, Project, ActivityLog, MemoryEmbedding) with RLS preparation - NestJS: PrismaModule, DatabaseModule, EmbeddingsService - Shared: Type-safe enums, constants, and database types Fixes #2 Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import { Controller, Get } from "@nestjs/common";
|
|
import { AppService } from "./app.service";
|
|
import { PrismaService } from "./prisma/prisma.service";
|
|
import type { ApiResponse, HealthStatus } from "@mosaic/shared";
|
|
import { successResponse } from "@mosaic/shared";
|
|
|
|
@Controller()
|
|
export class AppController {
|
|
constructor(
|
|
private readonly appService: AppService,
|
|
private readonly prisma: PrismaService,
|
|
) {}
|
|
|
|
@Get()
|
|
getHello(): string {
|
|
return this.appService.getHello();
|
|
}
|
|
|
|
@Get("health")
|
|
async getHealth(): Promise<ApiResponse<HealthStatus>> {
|
|
const dbHealthy = await this.prisma.isHealthy();
|
|
const dbInfo = await this.prisma.getConnectionInfo();
|
|
|
|
const overallStatus = dbHealthy ? "healthy" : "degraded";
|
|
const packageVersion = process.env.npm_package_version;
|
|
|
|
return successResponse({
|
|
status: overallStatus,
|
|
timestamp: new Date().toISOString(),
|
|
...(packageVersion && { version: packageVersion }),
|
|
checks: {
|
|
database: {
|
|
status: dbHealthy ? "healthy" : "unhealthy",
|
|
message: dbInfo.connected
|
|
? `Connected to ${dbInfo.database} (${dbInfo.version})`
|
|
: "Database connection failed",
|
|
},
|
|
},
|
|
});
|
|
}
|
|
}
|