-
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.
* feat(api): add `/healthz` endpoint * feat(web): add `/healthz` endpoint * ci: add healthcheck to containers * chore(release): bump versions - [email protected] - [email protected]
- Loading branch information
Showing
19 changed files
with
318 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,17 @@ | |
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
# [0.4.0](https://github.com/lharti/jsonthing/compare/[email protected]@0.4.0) (2024-11-16) | ||
|
||
|
||
### Features | ||
|
||
* **api:** add `/healthz` endpoint ([217927e](https://github.com/lharti/jsonthing/commit/217927e4910e9696fcbd816d6cd483687128dcec)) | ||
|
||
|
||
|
||
|
||
|
||
# [0.3.0](https://github.com/lharti/jsonthing/compare/[email protected]@0.3.0) (2024-11-12) | ||
|
||
|
||
|
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
"dictionaries": [], | ||
"words": [ | ||
"dtos", | ||
"Healthz", | ||
"jsonthing", | ||
"mockingoose", | ||
"nestjs", | ||
|
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
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
62 changes: 62 additions & 0 deletions
62
apps/jsonthing-api/src/routes/healthz/healthz.controller.spec.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,62 @@ | ||
import { | ||
HealthCheckService, | ||
MongooseHealthIndicator, | ||
} from '@nestjs/terminus' | ||
import { Test, TestingModule } from '@nestjs/testing' | ||
import { HealthzController } from './healthz.controller' | ||
|
||
describe('healthzController', () => { | ||
let testModule: TestingModule | ||
let controller: HealthzController | ||
|
||
beforeAll(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
controllers: [HealthzController], | ||
providers: [ | ||
{ | ||
provide: HealthCheckService, | ||
|
||
useValue: { | ||
check: jest.fn(checksFuncs => | ||
checksFuncs[0](), | ||
), | ||
}, | ||
}, | ||
|
||
{ | ||
provide: MongooseHealthIndicator, | ||
|
||
useValue: { | ||
pingCheck: jest.fn(key => | ||
Promise.resolve({ | ||
[key]: { status: 'up' }, | ||
}), | ||
), | ||
}, | ||
}, | ||
], | ||
}).compile() | ||
|
||
controller = module.get<HealthzController>(HealthzController) | ||
|
||
testModule = module | ||
}) | ||
|
||
afterAll(async () => { | ||
await testModule.close() | ||
}) | ||
|
||
it('should call health check service with mongoose ping check', async () => { | ||
expect.assertions(1) | ||
|
||
const checkResult = await controller.check() | ||
|
||
expect(checkResult).toMatchInlineSnapshot(` | ||
{ | ||
"mongoose": { | ||
"status": "up", | ||
}, | ||
} | ||
`) | ||
}) | ||
}) |
22 changes: 22 additions & 0 deletions
22
apps/jsonthing-api/src/routes/healthz/healthz.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,22 @@ | ||
import { Controller, Get } from '@nestjs/common' | ||
import { | ||
HealthCheck, | ||
HealthCheckService, | ||
MongooseHealthIndicator, | ||
} from '@nestjs/terminus' | ||
|
||
@Controller('healthz') | ||
export class HealthzController { | ||
constructor( | ||
private readonly health: HealthCheckService, | ||
private readonly mongoose: MongooseHealthIndicator, | ||
) {} | ||
|
||
@Get() | ||
@HealthCheck() | ||
check() { | ||
return this.health.check([ | ||
() => this.mongoose.pingCheck('mongoose'), | ||
]) | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
apps/jsonthing-api/src/routes/healthz/healthz.module.spec.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,34 @@ | ||
import { TerminusModule } from '@nestjs/terminus' | ||
import { Test, TestingModule } from '@nestjs/testing' | ||
import { HealthzController } from './healthz.controller' | ||
import { HealthzModule } from './healthz.module' | ||
|
||
describe('healthzModule', () => { | ||
let module: TestingModule | ||
|
||
beforeAll(async () => { | ||
module = await Test.createTestingModule({ | ||
imports: [HealthzModule], | ||
}).compile() | ||
}) | ||
|
||
afterAll(async () => { | ||
await module.close() | ||
}) | ||
|
||
it('should import TerminusModule', () => { | ||
expect.assertions(1) | ||
|
||
const terminusModule = module.get(TerminusModule) | ||
|
||
expect(terminusModule).toBeDefined() | ||
}) | ||
|
||
it('should have HealthzController', () => { | ||
expect.assertions(1) | ||
|
||
const healthzController = module.get(HealthzController) | ||
|
||
expect(healthzController).toBeDefined() | ||
}) | ||
}) |
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,9 @@ | ||
import { Module } from '@nestjs/common' | ||
import { TerminusModule } from '@nestjs/terminus' | ||
import { HealthzController } from './healthz.controller' | ||
|
||
@Module({ | ||
imports: [TerminusModule], | ||
controllers: [HealthzController], | ||
}) | ||
export class HealthzModule {} |
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 @@ | ||
export * from './healthz.module' |
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 |
---|---|---|
|
@@ -3,6 +3,17 @@ | |
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
# [0.6.0](https://github.com/lharti/jsonthing/compare/[email protected]@0.6.0) (2024-11-16) | ||
|
||
|
||
### Features | ||
|
||
* **web:** add `/healthz` endpoint ([16dbded](https://github.com/lharti/jsonthing/commit/16dbdedeebd1e79dd64566e8cfd2ec6f44651ea7)) | ||
|
||
|
||
|
||
|
||
|
||
## [0.5.8](https://github.com/lharti/jsonthing/compare/[email protected]@0.5.8) (2024-11-14) | ||
|
||
|
||
|
5 changes: 3 additions & 2 deletions
5
apps/jsonthing-web/next.config.mjs → apps/jsonthing-web/next.config.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
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,3 @@ | ||
export function GET() { | ||
return Response.json({ status: 'ok' }) | ||
} |
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 |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
}, | ||
"include": [ | ||
"next-env.d.ts", | ||
"next.config.ts", | ||
"**/*.ts", | ||
"**/*.tsx", | ||
".next/types/**/*.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
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
Oops, something went wrong.