From e178b643661aecf250c98664c7bde07d4519cce8 Mon Sep 17 00:00:00 2001 From: Dadam Rishikesh Reddy Date: Sun, 19 Apr 2026 08:12:52 +0530 Subject: [PATCH] refactor(express): split ping endpoint into v1 and v2 TICKET: WCI-187 --- modules/express/src/clientRoutes.ts | 1 + modules/express/src/typedRoutes/api/index.ts | 8 +++++-- .../express/src/typedRoutes/api/v1/ping.ts | 22 +++++++++++++++++++ .../typedRoutes/api/{common => v2}/ping.ts | 9 +++++--- 4 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 modules/express/src/typedRoutes/api/v1/ping.ts rename modules/express/src/typedRoutes/api/{common => v2}/ping.ts (64%) diff --git a/modules/express/src/clientRoutes.ts b/modules/express/src/clientRoutes.ts index b1f151031f..93bb68bbc9 100755 --- a/modules/express/src/clientRoutes.ts +++ b/modules/express/src/clientRoutes.ts @@ -1692,6 +1692,7 @@ export function setupAPIRoutes(app: express.Application, config: Config): void { const router = createExpressRouter(); app.use(router); + router.get('express.v1.ping', [prepareBitGo(config), typedPromiseWrapper(handlePing)]); router.get('express.ping', [prepareBitGo(config), typedPromiseWrapper(handlePing)]); router.get('express.pingExpress', [typedPromiseWrapper(handlePingExpress)]); diff --git a/modules/express/src/typedRoutes/api/index.ts b/modules/express/src/typedRoutes/api/index.ts index 0e7396bbae..9741c7a646 100644 --- a/modules/express/src/typedRoutes/api/index.ts +++ b/modules/express/src/typedRoutes/api/index.ts @@ -2,7 +2,8 @@ import * as t from 'io-ts'; import { apiSpec } from '@api-ts/io-ts-http'; import * as express from 'express'; -import { GetPing } from './common/ping'; +import { GetV1Ping } from './v1/ping'; +import { GetV2Ping } from './v2/ping'; import { GetPingExpress } from './common/pingExpress'; import { PostLogin } from './common/login'; import { PostV1Decrypt } from './v1/decrypt'; @@ -65,8 +66,11 @@ import { GetResourceDelegations } from './v2/resourceDelegations'; // inference stays small; (2) only construct expressApi with a single key and add it to the type union at the end. export const ExpressPingApiSpec = apiSpec({ + 'express.v1.ping': { + get: GetV1Ping, + }, 'express.ping': { - get: GetPing, + get: GetV2Ping, }, }); diff --git a/modules/express/src/typedRoutes/api/v1/ping.ts b/modules/express/src/typedRoutes/api/v1/ping.ts new file mode 100644 index 0000000000..71ab830057 --- /dev/null +++ b/modules/express/src/typedRoutes/api/v1/ping.ts @@ -0,0 +1,22 @@ +import * as t from 'io-ts'; +import { httpRoute, httpRequest } from '@api-ts/io-ts-http'; +import { BitgoExpressError } from '../../schemas/error'; + +/** + * Ping (v1) + * + * Health check endpoint that returns 200 when the Express server is running. + * + * @operationId express.v1.ping + * @tag Express + * @private + */ +export const GetV1Ping = httpRoute({ + path: '/api/v1/ping', + method: 'GET', + request: httpRequest({}), + response: { + 200: t.type({}), + 404: BitgoExpressError, + }, +}); diff --git a/modules/express/src/typedRoutes/api/common/ping.ts b/modules/express/src/typedRoutes/api/v2/ping.ts similarity index 64% rename from modules/express/src/typedRoutes/api/common/ping.ts rename to modules/express/src/typedRoutes/api/v2/ping.ts index 426adefdae..188dab3a49 100644 --- a/modules/express/src/typedRoutes/api/common/ping.ts +++ b/modules/express/src/typedRoutes/api/v2/ping.ts @@ -5,11 +5,14 @@ import { BitgoExpressError } from '../../schemas/error'; /** * Ping * + * Health check endpoint that returns 200 when the Express server is running. + * * @operationId express.ping - * @tag express + * @tag Express + * @public */ -export const GetPing = httpRoute({ - path: '/api/v[12]/ping', +export const GetV2Ping = httpRoute({ + path: '/api/v2/ping', method: 'GET', request: httpRequest({}), response: {