Skip to content

Commit 755f8ee

Browse files
committed
refactor: added docs and updated req type
TICKET: WP-5414
1 parent 96e3ec0 commit 755f8ee

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

modules/express/src/clientRoutes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ async function handleV2PendingApproval(req: express.Request): Promise<any> {
685685
* create a keychain
686686
* @param req
687687
*/
688-
function handleV2CreateLocalKeyChain(req: express.Request) {
688+
function handleV2CreateLocalKeyChain(req: ExpressApiRouteRequest<'express.keychain.local', 'post'>) {
689689
const bitgo = req.bitgo;
690690
const coin = bitgo.coin(req.params.coin);
691691
return coin.keychains().create(req.body);

modules/express/src/typedRoutes/api/v2/keychainLocal.ts

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

55
/**
6+
* Request parameters for creating a local keychain
67
* @property {string} coin - Coin identifier (e.g. btc, tbtc, eth)
78
*/
89
export const KeychainLocalRequestParams = {
10+
/** Coin identifier (e.g. btc, tbtc, eth) */
911
coin: t.string,
10-
};
12+
} as const;
13+
14+
/**
15+
* Response for creating a local keychain
16+
*/
17+
export const KeychainLocalResponse = {
18+
/** Newly generated local keychain. */
19+
200: t.type({
20+
prv: t.string,
21+
pub: t.string,
22+
}),
23+
/** Invalid request or key generation fails. */
24+
400: BitgoExpressError,
25+
} as const;
1126

1227
/**
1328
* Local client-side function to create a new keychain.
@@ -24,11 +39,5 @@ export const PostKeychainLocal = httpRoute({
2439
request: httpRequest({
2540
params: KeychainLocalRequestParams,
2641
}),
27-
response: {
28-
200: t.type({
29-
prv: t.string,
30-
pub: t.string,
31-
}),
32-
400: BitgoExpressError,
33-
},
42+
response: KeychainLocalResponse,
3443
});

0 commit comments

Comments
 (0)