forked from will2hew/docmost
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
39 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { KyselyDB } from '@docmost/db/types/kysely.types'; | ||
import { | ||
Controller, | ||
Get, | ||
HttpCode, | ||
HttpStatus, | ||
InternalServerErrorException, | ||
Post, | ||
} from '@nestjs/common'; | ||
import { sql } from 'kysely'; | ||
import { InjectKysely } from 'nestjs-kysely'; | ||
|
||
@Controller() | ||
export class HealthController { | ||
constructor(@InjectKysely() private readonly db: KyselyDB) {} | ||
|
||
@Get('health') | ||
@HttpCode(HttpStatus.OK) | ||
async health() { | ||
try { | ||
await sql`SELECT 1=1`.execute(this.db); | ||
} catch (error) { | ||
throw new InternalServerErrorException('Health check failed'); | ||
} | ||
} | ||
} |
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,8 @@ | ||
import { Global, Module } from '@nestjs/common'; | ||
import { HealthController } from './health.controller'; | ||
|
||
@Global() | ||
@Module({ | ||
controllers: [HealthController], | ||
}) | ||
export class HealthModule {} |
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