feat: Initialize NestJS backend project with Prisma, core modules, configuration, and common utilities.
This commit is contained in:
38
src/app.service.ts
Normal file
38
src/app.service.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { PrismaService } from './prisma';
|
||||
|
||||
@Injectable()
|
||||
export class AppService {
|
||||
constructor(
|
||||
private readonly configService: ConfigService,
|
||||
private readonly prisma: PrismaService,
|
||||
) {}
|
||||
|
||||
getHello(): string {
|
||||
return 'Real Estate Agent Platform API v1.0';
|
||||
}
|
||||
|
||||
async getHealth() {
|
||||
const dbHealthy = await this.checkDatabaseHealth();
|
||||
|
||||
return {
|
||||
status: 'ok',
|
||||
timestamp: new Date().toISOString(),
|
||||
environment: this.configService.get<string>('app.env'),
|
||||
version: '1.0.0',
|
||||
services: {
|
||||
database: dbHealthy ? 'healthy' : 'unhealthy',
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
private async checkDatabaseHealth(): Promise<boolean> {
|
||||
try {
|
||||
await this.prisma.$queryRaw`SELECT 1`;
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user