-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: healthcheck for external services (#4048)
* chore: installed terminus package and scaffolded the health module * feat: added healthcheck for database with prisma * chore: renamed label from prisma to database in health check route * chore: reverted target of hopp-old-backend service to prod
- Loading branch information
Showing
5 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/hoppscotch-backend/src/health/health.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Controller, Get } from '@nestjs/common'; | ||
import { | ||
HealthCheck, | ||
HealthCheckService, | ||
PrismaHealthIndicator, | ||
} from '@nestjs/terminus'; | ||
import { PrismaService } from 'src/prisma/prisma.service'; | ||
|
||
@Controller('health') | ||
export class HealthController { | ||
constructor( | ||
private health: HealthCheckService, | ||
private prismaHealth: PrismaHealthIndicator, | ||
private prisma: PrismaService, | ||
) {} | ||
|
||
@Get() | ||
@HealthCheck() | ||
check() { | ||
return this.health.check([ | ||
async () => this.prismaHealth.pingCheck('database', this.prisma), | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { HealthController } from './health.controller'; | ||
import { PrismaModule } from 'src/prisma/prisma.module'; | ||
import { TerminusModule } from '@nestjs/terminus'; | ||
|
||
@Module({ | ||
imports: [PrismaModule, TerminusModule], | ||
controllers: [HealthController], | ||
}) | ||
export class HealthModule {} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.