Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions modules/express/src/clientRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function handlePing(
return req.bitgo.ping();
}

function handlePingExpress(req: ExpressApiRouteRequest<'express.pingExpress', 'get'>) {
function handlePingExpress(req: ExpressApiRouteRequest<'express.pingexpress', 'get'>) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handlePingExpress is wired to both express.v1.pingexpress and express.pingexpress, but the parameter type only mentions express.pingexpress. Update to ExpressApiRouteRequest<'express.v1.pingexpress' | 'express.pingexpress', 'get'> so the type matches both registrations.

return {
status: 'express server is ok!',
};
Expand Down Expand Up @@ -1693,7 +1693,8 @@ export function setupAPIRoutes(app: express.Application, config: Config): void {
app.use(router);

router.get('express.ping', [prepareBitGo(config), typedPromiseWrapper(handlePing)]);
router.get('express.pingExpress', [typedPromiseWrapper(handlePingExpress)]);
router.get('express.v1.pingexpress', [typedPromiseWrapper(handlePingExpress)]);
router.get('express.pingexpress', [typedPromiseWrapper(handlePingExpress)]);

// auth
router.post('express.login', [prepareBitGo(config), typedPromiseWrapper(handleLogin)]);
Expand Down
10 changes: 7 additions & 3 deletions modules/express/src/typedRoutes/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { apiSpec } from '@api-ts/io-ts-http';
import * as express from 'express';

import { GetPing } from './common/ping';
import { GetPingExpress } from './common/pingExpress';
import { GetV1PingExpress } from './v1/pingExpress';
import { GetV2PingExpress } from './v2/pingExpress';
import { PostLogin } from './common/login';
import { PostV1Decrypt } from './v1/decrypt';
import { PostV2Decrypt } from './v2/decrypt';
Expand Down Expand Up @@ -71,8 +72,11 @@ export const ExpressPingApiSpec = apiSpec({
});

export const ExpressPingExpressApiSpec = apiSpec({
'express.pingExpress': {
get: GetPingExpress,
'express.v1.pingexpress': {
get: GetV1PingExpress,
},
'express.pingexpress': {
get: GetV2PingExpress,
},
});

Expand Down
22 changes: 22 additions & 0 deletions modules/express/src/typedRoutes/api/v1/pingExpress.ts
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a minimal test that both GET /api/v1/pingexpress and GET /api/v2/pingexpress resolve and return the expected payload

Original file line number Diff line number Diff line change
@@ -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 BitGo Express (v1)
*
* Ping bitgo express to ensure that it is still running. Unlike /ping, this does not try connecting to bitgo.com.
*
* @operationId express.v1.pingexpress
* @tag Express
* @private
*/
export const GetV1PingExpress = httpRoute({
path: '/api/v1/pingexpress',
method: 'GET',
request: httpRequest({}),
response: {
200: t.type({ status: t.string }),
404: BitgoExpressError,
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ import { httpRoute, httpRequest } from '@api-ts/io-ts-http';
import { BitgoExpressError } from '../../schemas/error';

/**
* Ping Express
* Ping BitGo Express
*
* @operationId express.pingExpress
* @tag express
* Ping bitgo express to ensure that it is still running. Unlike /ping, this does not try connecting to bitgo.com.
*
* @operationId express.pingexpress
* @tag Express
* @public
*/
export const GetPingExpress = httpRoute({
path: '/api/v[12]/pingexpress',
export const GetV2PingExpress = httpRoute({
path: '/api/v2/pingexpress',
method: 'GET',
request: httpRequest({}),
response: {
Expand Down
Loading