Skip to content

Commit 2eacc1e

Browse files
Merge pull request #19954 from mozilla/add-service-endpoints
feat(payments-api): Add version and heartbeat endpoints to payments-api
2 parents 766ce33 + f1b9414 commit 2eacc1e

4 files changed

Lines changed: 65 additions & 11 deletions

File tree

apps/payments/api/src/app/app.controller.spec.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,26 @@ describe('AppController', () => {
1313
});
1414

1515
describe('getData', () => {
16-
it('should return "Hello API"', () => {
16+
it('should return "Hello world"', () => {
1717
const appController = app.get<AppController>(AppController);
18-
expect(appController.getData()).toEqual({ message: 'Hello API' });
18+
expect(appController.getData()).toEqual({ message: 'Hello world' });
19+
});
20+
});
21+
22+
describe('service status endpoints', () => {
23+
it('__heartbeat__ should return empty object', () => {
24+
const appController = app.get<AppController>(AppController);
25+
expect(appController.__heartbeat__()).toEqual({});
26+
});
27+
28+
it('__lbheartbeat__ should return empty object', () => {
29+
const appController = app.get<AppController>(AppController);
30+
expect(appController.__lbheartbeat__()).toEqual({});
31+
});
32+
33+
it('__version__ should return version object', () => {
34+
const appController = app.get<AppController>(AppController);
35+
expect(appController.__version__()).toEqual({ version: '0.0.0' });
1936
});
2037
});
2138
});

apps/payments/api/src/app/app.controller.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,19 @@ export class AppController {
99
getData() {
1010
return this.appService.getData();
1111
}
12+
13+
@Get('__lbheartbeat__')
14+
__lbheartbeat__() {
15+
return this.appService.__lbheartbeat__();
16+
}
17+
18+
@Get('__heartbeat__')
19+
__heartbeat__() {
20+
return this.appService.__heartbeat__();
21+
}
22+
23+
@Get('__version__')
24+
__version__() {
25+
return this.appService.__version__();
26+
}
1227
}

apps/payments/api/src/app/app.service.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,18 @@ describe('AppService', () => {
1717
expect(service.getData()).toEqual({ message: 'Hello API' });
1818
});
1919
});
20+
21+
describe('service status endpoints', () => {
22+
it('__heartbeat__ should return empty object', () => {
23+
expect(service.__heartbeat__()).toEqual({});
24+
});
25+
26+
it('__lbheartbeat__ should return empty object', () => {
27+
expect(service.__lbheartbeat__()).toEqual({});
28+
});
29+
30+
it('__version__ should return version object', () => {
31+
expect(service.__version__()).toEqual({ version: '0.0.0' });
32+
});
33+
});
2034
});
Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
import { Injectable } from '@nestjs/common';
2-
import { RootConfig } from '../config';
32

43
@Injectable()
54
export class AppService {
6-
constructor(private config: RootConfig) {}
5+
constructor() {}
76

8-
getData(): {
9-
message: string;
10-
config: RootConfig;
11-
} {
12-
console.log('All config', this.config);
7+
getData() {
138
return {
14-
message: 'Hello API',
15-
config: this.config,
9+
message: 'Hello world',
10+
};
11+
}
12+
13+
__heartbeat__() {
14+
return {};
15+
}
16+
17+
__lbheartbeat__() {
18+
return {};
19+
}
20+
21+
__version__() {
22+
return {
23+
version: '0.0.0',
1624
};
1725
}
1826
}

0 commit comments

Comments
 (0)