Skip to content

Commit e178b64

Browse files
refactor(express): split ping endpoint into v1 and v2
TICKET: WCI-187
1 parent 4c753e1 commit e178b64

4 files changed

Lines changed: 35 additions & 5 deletions

File tree

modules/express/src/clientRoutes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,6 +1692,7 @@ export function setupAPIRoutes(app: express.Application, config: Config): void {
16921692
const router = createExpressRouter();
16931693
app.use(router);
16941694

1695+
router.get('express.v1.ping', [prepareBitGo(config), typedPromiseWrapper(handlePing)]);
16951696
router.get('express.ping', [prepareBitGo(config), typedPromiseWrapper(handlePing)]);
16961697
router.get('express.pingExpress', [typedPromiseWrapper(handlePingExpress)]);
16971698

modules/express/src/typedRoutes/api/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import * as t from 'io-ts';
22
import { apiSpec } from '@api-ts/io-ts-http';
33
import * as express from 'express';
44

5-
import { GetPing } from './common/ping';
5+
import { GetV1Ping } from './v1/ping';
6+
import { GetV2Ping } from './v2/ping';
67
import { GetPingExpress } from './common/pingExpress';
78
import { PostLogin } from './common/login';
89
import { PostV1Decrypt } from './v1/decrypt';
@@ -65,8 +66,11 @@ import { GetResourceDelegations } from './v2/resourceDelegations';
6566
// inference stays small; (2) only construct expressApi with a single key and add it to the type union at the end.
6667

6768
export const ExpressPingApiSpec = apiSpec({
69+
'express.v1.ping': {
70+
get: GetV1Ping,
71+
},
6872
'express.ping': {
69-
get: GetPing,
73+
get: GetV2Ping,
7074
},
7175
});
7276

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import * as t from 'io-ts';
2+
import { httpRoute, httpRequest } from '@api-ts/io-ts-http';
3+
import { BitgoExpressError } from '../../schemas/error';
4+
5+
/**
6+
* Ping (v1)
7+
*
8+
* Health check endpoint that returns 200 when the Express server is running.
9+
*
10+
* @operationId express.v1.ping
11+
* @tag Express
12+
* @private
13+
*/
14+
export const GetV1Ping = httpRoute({
15+
path: '/api/v1/ping',
16+
method: 'GET',
17+
request: httpRequest({}),
18+
response: {
19+
200: t.type({}),
20+
404: BitgoExpressError,
21+
},
22+
});

modules/express/src/typedRoutes/api/common/ping.ts renamed to modules/express/src/typedRoutes/api/v2/ping.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@ import { BitgoExpressError } from '../../schemas/error';
55
/**
66
* Ping
77
*
8+
* Health check endpoint that returns 200 when the Express server is running.
9+
*
810
* @operationId express.ping
9-
* @tag express
11+
* @tag Express
12+
* @public
1013
*/
11-
export const GetPing = httpRoute({
12-
path: '/api/v[12]/ping',
14+
export const GetV2Ping = httpRoute({
15+
path: '/api/v2/ping',
1316
method: 'GET',
1417
request: httpRequest({}),
1518
response: {

0 commit comments

Comments
 (0)