Skip to content

Commit 59d2c84

Browse files
refactor(express): split ping endpoint into v1 and v2
TICKET: WCI-187
1 parent d067420 commit 59d2c84

4 files changed

Lines changed: 36 additions & 10 deletions

File tree

modules/express/src/clientRoutes.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ const BITGOEXPRESS_USER_AGENT = `BitGoExpress/${pjson.version} BitGoJS/${version
7676
const FORWARDED_HEADERS = ['x-bitgo-otp'];
7777

7878
function handlePing(
79-
req: ExpressApiRouteRequest<'express.ping', 'get'>,
79+
req: ExpressApiRouteRequest<'express.v2.ping', 'get'>,
8080
res: express.Response,
8181
next: express.NextFunction
8282
) {
@@ -1694,7 +1694,8 @@ export function setupAPIRoutes(app: express.Application, config: Config): void {
16941694
const router = createExpressRouter();
16951695
app.use(router);
16961696

1697-
router.get('express.ping', [prepareBitGo(config), typedPromiseWrapper(handlePing)]);
1697+
router.get('express.v1.ping', [prepareBitGo(config), typedPromiseWrapper(handlePing)]);
1698+
router.get('express.v2.ping', [prepareBitGo(config), typedPromiseWrapper(handlePing)]);
16981699
router.get('express.pingExpress', [typedPromiseWrapper(handlePingExpress)]);
16991700

17001701
// auth

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

Lines changed: 7 additions & 3 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 { PostDecrypt } from './common/decrypt';
@@ -63,8 +64,11 @@ import { GetResourceDelegations } from './v2/resourceDelegations';
6364
// inference stays small; (2) only construct expressApi with a single key and add it to the type union at the end.
6465

6566
export const ExpressPingApiSpec = apiSpec({
66-
'express.ping': {
67-
get: GetPing,
67+
'express.v1.ping': {
68+
get: GetV1Ping,
69+
},
70+
'express.v2.ping': {
71+
get: GetV2Ping,
6872
},
6973
});
7074

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import { httpRoute, httpRequest } from '@api-ts/io-ts-http';
33
import { BitgoExpressError } from '../../schemas/error';
44

55
/**
6-
* Ping
6+
* Ping (v1)
77
*
8-
* @operationId express.ping
9-
* @tag express
8+
* @operationId express.v1.ping
9+
* @tag Express
1010
*/
11-
export const GetPing = httpRoute({
12-
path: '/api/v[12]/ping',
11+
export const GetV1Ping = httpRoute({
12+
path: '/api/v1/ping',
1313
method: 'GET',
1414
request: httpRequest({}),
1515
response: {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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
7+
*
8+
* Health check endpoint that returns 200 when the Express server is running.
9+
*
10+
* @operationId express.v2.ping
11+
* @tag Express
12+
*/
13+
export const GetV2Ping = httpRoute({
14+
path: '/api/v2/ping',
15+
method: 'GET',
16+
request: httpRequest({}),
17+
response: {
18+
200: t.type({}),
19+
404: BitgoExpressError,
20+
},
21+
});

0 commit comments

Comments
 (0)