Skip to content

Commit 1b30004

Browse files
committed
feat(healthz): add app version to response body
1 parent dde16bf commit 1b30004

File tree

5 files changed

+26
-2
lines changed

5 files changed

+26
-2
lines changed

src/application/health/health-status.response.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import { HealthStatus } from '@domain/health/health-status';
2+
import { AppInfo } from '@presentation/config/app.config';
23

34
class HealthStatusResponse {
45
readonly status: string;
56

67
readonly message: string;
78

9+
readonly appVersion = AppInfo.APP_VERSION;
10+
811
constructor(status: string, message: string) {
912
this.status = status;
1013
this.message = message;

src/presentation/app.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ class App {
122122
Version: ${AppInfo.APP_VERSION}
123123
Port: ${this.port}
124124
Base Path: ${this.basePath}
125+
OpenApi Spec Path: ${this.basePath}/spec
125126
Environment: ${this.env}
126127
Author: ${AppInfo.AUTHOR_NAME}
127128
Email: ${AppInfo.AUTHOR_EMAIL}

src/presentation/controllers/health/health.oas.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ components:
3636
type: string
3737
description: Description of server status
3838
example: '🚀 To infinity and beyond!'
39+
timestamp:
40+
type: string
41+
description: Timestamp of server status
42+
example: '2020-01-01T00:00:00Z'
43+
appVersion:
44+
type: string
45+
description: Application version
46+
example: '1.0.0'
3947
ErrorResponse:
4048
type: object
4149
properties:
@@ -51,3 +59,11 @@ components:
5159
type: string
5260
description: Error description
5361
example: 'Unexpected internal server error'
62+
timestamp:
63+
type: string
64+
description: Timestamp of server status
65+
example: '2020-01-01T00:00:00Z'
66+
appVersion:
67+
type: string
68+
description: Application version
69+
example: '1.0.0'

src/presentation/errors/error.response.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
import { AppInfo } from '@presentation/config/app.config';
2+
13
class ErrorResponse {
24
public status: number;
35

46
public code: string;
57

68
public message: string;
79

10+
readonly appVersion = AppInfo.APP_VERSION;
11+
812
constructor(status: number, code: string, message: string) {
913
this.status = status;
1014
this.code = code;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { HealthCheckerUseCase } from '@application/health/health-checker.usecase';
2-
import { HealthStatus } from '@domain/health/health-status';
2+
import { HealthStatusResponse } from '@application/health/health-status.response';
33

44
describe('Testing health check use case', () => {
55
it('should return ALIVE health status', () => {
66
const healthCheckerUseCase = new HealthCheckerUseCase();
77
return expect(healthCheckerUseCase.execute()).resolves.toEqual(
8-
new HealthStatus('ALIVE', '🚀 To infinity and beyond!')
8+
new HealthStatusResponse('ALIVE', '🚀 To infinity and beyond!')
99
);
1010
});
1111
});

0 commit comments

Comments
 (0)