forked from mtusi2026/mtusi2026lab2
feat(api): persist messenger data with Bearer auth and versioned Redis cache
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { Controller, Get, HttpStatus } from '@nestjs/common';
|
||||
import { AppService } from './app.service';
|
||||
import { PrismaService } from './prisma/prisma.service';
|
||||
import { ApiException } from './common/exceptions/api.exception';
|
||||
|
||||
@Controller()
|
||||
export class AppController {
|
||||
constructor(
|
||||
private readonly appService: AppService,
|
||||
private readonly prisma: PrismaService,
|
||||
) {}
|
||||
|
||||
@Get()
|
||||
getHello(): string {
|
||||
return this.appService.getHello();
|
||||
}
|
||||
|
||||
@Get('health/live')
|
||||
live() {
|
||||
return { status: 'ok' };
|
||||
}
|
||||
|
||||
@Get('health/ready')
|
||||
async ready() {
|
||||
try {
|
||||
await this.prisma.$queryRaw`SELECT 1`;
|
||||
} catch {
|
||||
throw new ApiException(
|
||||
HttpStatus.SERVICE_UNAVAILABLE,
|
||||
'unavailable',
|
||||
'База данных недоступна',
|
||||
);
|
||||
}
|
||||
return { status: 'ok' };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user