Skip to content

Commit 6665d87

Browse files
committed
chore(express): convert post to get and add logs
TICKET: WP-4376
1 parent 8ca192c commit 6665d87

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

modules/express/src/clientRoutes.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,8 +1771,9 @@ export function setupSigningRoutes(app: express.Application, config: Config): vo
17711771
);
17721772
}
17731773

1774-
export function setupEnclavedSigningRoutes(app: express.Application, config: Config): void {
1775-
app.post('/ping/enclavedExpress', parseBody, prepareBitGo(config), promiseWrapper(handlePingEnclavedExpress));
1774+
export function setupEnclavedExpressRoutes(app: express.Application, config: Config): void {
1775+
// Keep the ping endpoint for health checks
1776+
app.get('/ping/enclavedExpress', parseBody, prepareBitGo(config), promiseWrapper(handlePingEnclavedExpress));
17761777
}
17771778

17781779
export function setupLightningSignerNodeRoutes(app: express.Application, config: Config): void {

modules/express/src/enclavedExpressRoutes/enclavedExpressRoutes.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import * as express from 'express';
44
import { retryPromise } from '../retryPromise';
55

66
export async function handlePingEnclavedExpress(req: express.Request) {
7+
console.log('Making enclaved express request with SSL cert to:', req.config?.enclavedExpressUrl);
78
return await retryPromise(
89
() =>
910
superagent
10-
.post(`${req.config?.enclavedExpressUrl}/ping`)
11+
.get(`${req.config?.enclavedExpressUrl}/ping`)
1112
.ca(req.config?.enclavedExpressSSLCert as string)
12-
.send({}),
13+
.send(),
1314
(err, tryCount) => {
1415
debug(`Failed to ping enclavedExpress: ${err.message}`);
1516
}

modules/express/src/expressApp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ export function setupRoutes(app: express.Application, config: Config): void {
287287
if (config.signerMode) {
288288
clientRoutes.setupSigningRoutes(app, config);
289289
} else if (config.enclavedExpressUrl && config.enclavedExpressSSLCert) {
290-
clientRoutes.setupEnclavedSigningRoutes(app, config);
290+
clientRoutes.setupEnclavedExpressRoutes(app, config);
291291
} else {
292292
if (config.lightningSignerFileSystemPath) {
293293
clientRoutes.setupLightningSignerNodeRoutes(app, config);

modules/express/test/unit/config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ describe('Config:', () => {
8383
customrooturi: 'argcustomRootUri',
8484
custombitcoinnetwork: 'argcustomBitcoinNetwork',
8585
externalSignerUrl: 'argexternalSignerUrl',
86+
enclavedExpressUrl: 'argenclavedExpressUrl',
87+
enclavedExpressSSLCert: 'argenclavedExpressSSLCert',
8688
signerMode: 'argsignerMode',
8789
signerFileSystemPath: 'argsignerFileSystemPath',
8890
lightningSignerFileSystemPath: 'arglightningSignerFileSystemPath',
@@ -107,6 +109,8 @@ describe('Config:', () => {
107109
BITGO_CUSTOM_ROOT_URI: 'envcustomRootUri',
108110
BITGO_CUSTOM_BITCOIN_NETWORK: 'envcustomBitcoinNetwork',
109111
BITGO_EXTERNAL_SIGNER_URL: 'envexternalSignerUrl',
112+
BITGO_ENCLAVED_EXPRESS_URL: 'envenclavedExpressUrl',
113+
BITGO_ENCLAVED_EXPRESS_SSL_CERT: 'envenclavedExpressSSLCert',
110114
BITGO_SIGNER_MODE: 'envsignerMode',
111115
BITGO_SIGNER_FILE_SYSTEM_PATH: 'envsignerFileSystemPath',
112116
BITGO_LIGHTNING_SIGNER_FILE_SYSTEM_PATH: 'envlightningSignerFileSystemPath',
@@ -132,6 +136,8 @@ describe('Config:', () => {
132136
customBitcoinNetwork: 'argcustomBitcoinNetwork',
133137
authVersion: 2,
134138
externalSignerUrl: 'https://argexternalSignerUrl',
139+
enclavedExpressUrl: 'https://argenclavedExpressUrl',
140+
enclavedExpressSSLCert: 'argenclavedExpressSSLCert',
135141
signerMode: 'argsignerMode',
136142
signerFileSystemPath: 'argsignerFileSystemPath',
137143
lightningSignerFileSystemPath: 'arglightningSignerFileSystemPath',

0 commit comments

Comments
 (0)