Skip to content

Commit 1048583

Browse files
authored
Merge pull request #5800 from BitGo/DX-1163-remove-bluebird-from-bitgo-express
refactor(express): replace bluebird with native promises
2 parents beb83af + c95152e commit 1048583

File tree

4 files changed

+55
-70
lines changed

4 files changed

+55
-70
lines changed

modules/express/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
"@types/proxyquire": "^1.3.31",
4444
"argparse": "^1.0.10",
4545
"bitgo": "^42.2.0",
46-
"bluebird": "^3.5.3",
4746
"body-parser": "^1.20.3",
4847
"connect-timeout": "^1.9.0",
4948
"debug": "^3.1.0",
@@ -61,7 +60,6 @@
6160
"@bitgo/sdk-lib-mpc": "^10.1.2",
6261
"@bitgo/sdk-test": "^8.0.76",
6362
"@types/argparse": "^1.0.36",
64-
"@types/bluebird": "^3.5.25",
6563
"@types/body-parser": "^1.17.0",
6664
"@types/express": "4.17.13",
6765
"@types/lodash": "^4.14.121",

modules/express/test/unit/bitgoExpress.ts

Lines changed: 33 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import * as https from 'https';
1212
import * as debugLib from 'debug';
1313
import * as path from 'path';
1414
import { Environments } from 'bitgo';
15-
import { coroutine as co } from 'bluebird';
1615

1716
import { SSL_OP_NO_TLSv1 } from 'constants';
1817
import { TlsConfigurationError, NodeEnvironmentError } from '../../src/errors';
@@ -112,50 +111,44 @@ describe('Bitgo Express', function () {
112111
(() => expressApp(args)).should.throw(TlsConfigurationError);
113112
});
114113

115-
it(
116-
'should create an http server when not using TLS',
117-
co(function* () {
118-
const createServerStub = sinon.stub(http, 'createServer');
114+
it('should create an http server when not using TLS', async function () {
115+
const createServerStub = sinon.stub(http, 'createServer');
119116

120-
const args: any = {
121-
env: 'prod',
122-
bind: 'localhost',
123-
};
117+
const args: any = {
118+
env: 'prod',
119+
bind: 'localhost',
120+
};
124121

125-
createServer(args, null as any);
122+
createServer(args, null as any);
126123

127-
createServerStub.should.be.calledOnce();
128-
createServerStub.restore();
129-
})
130-
);
131-
132-
it(
133-
'should create an https server when using TLS',
134-
co(function* () {
135-
const createServerStub = sinon.stub(https, 'createServer');
136-
const readFileAsyncStub = sinon
137-
.stub(fs.promises, 'readFile' as any)
138-
.onFirstCall()
139-
.resolves('key')
140-
.onSecondCall()
141-
.resolves('cert');
142-
143-
const args: any = {
144-
env: 'prod',
145-
bind: '1.2.3.4',
146-
crtPath: '/tmp/crt.pem',
147-
keyPath: '/tmp/key.pem',
148-
};
149-
150-
yield createServer(args, null as any);
124+
createServerStub.should.be.calledOnce();
125+
createServerStub.restore();
126+
});
151127

152-
https.createServer.should.be.calledOnce();
153-
https.createServer.should.be.calledWith({ secureOptions: SSL_OP_NO_TLSv1, key: 'key', cert: 'cert' });
128+
it('should create an https server when using TLS', async function () {
129+
const createServerStub = sinon.stub(https, 'createServer');
130+
const readFileAsyncStub = sinon
131+
.stub(fs.promises, 'readFile' as any)
132+
.onFirstCall()
133+
.resolves('key')
134+
.onSecondCall()
135+
.resolves('cert');
154136

155-
createServerStub.restore();
156-
readFileAsyncStub.restore();
157-
})
158-
);
137+
const args: any = {
138+
env: 'prod',
139+
bind: '1.2.3.4',
140+
crtPath: '/tmp/crt.pem',
141+
keyPath: '/tmp/key.pem',
142+
};
143+
144+
await createServer(args, null as any);
145+
146+
https.createServer.should.be.calledOnce();
147+
https.createServer.should.be.calledWith({ secureOptions: SSL_OP_NO_TLSv1, key: 'key', cert: 'cert' });
148+
149+
createServerStub.restore();
150+
readFileAsyncStub.restore();
151+
});
159152

160153
it('should create https server with sslkey and sslcert', async () => {
161154
const createServerStub = sinon.stub(https, 'createServer');

modules/express/test/unit/clientRoutes/generateWallet.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as sinon from 'sinon';
2-
import * as Bluebird from 'bluebird';
32

43
import 'should-http';
54
import 'should-sinon';
@@ -15,7 +14,7 @@ import { BaseCoin, Wallets, WalletWithKeychains } from '@bitgo/sdk-core';
1514
describe('Generate Wallet', () => {
1615
it('should return the internal wallet object and keychains by default or if includeKeychains is true', async () => {
1716
const walletStub = sinon
18-
.stub<[], Bluebird<WalletWithKeychains>>()
17+
.stub<[], Promise<WalletWithKeychains>>()
1918
.resolves({ wallet: { toJSON: () => 'walletdata with keychains' } } as any);
2019
const walletsStub = sinon.createStubInstance(Wallets, { generateWallet: walletStub });
2120
const coinStub = sinon.createStubInstance(BaseCoin, {

yarn.lock

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,10 @@
135135
regexpu-core "^6.2.0"
136136
semver "^6.3.1"
137137

138-
"@babel/helper-define-polyfill-provider@^0.6.3":
139-
version "0.6.3"
140-
resolved "https://registry.npmjs.org/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.6.3.tgz#f4f2792fae2ef382074bc2d713522cf24e6ddb21"
141-
integrity sha512-HK7Bi+Hj6H+VTHA3ZvBis7V/6hu9QuTrnMXNybfUf2iiuU/N97I8VjB+KbhFF8Rld/Lx5MzoCwPCpPjfK+n8Cg==
138+
"@babel/helper-define-polyfill-provider@^0.6.3", "@babel/helper-define-polyfill-provider@^0.6.4":
139+
version "0.6.4"
140+
resolved "https://registry.npmjs.org/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.6.4.tgz#15e8746368bfa671785f5926ff74b3064c291fab"
141+
integrity sha512-jljfR1rGnXXNWnmQg2K3+bvhkxB51Rl32QRaOTuwwjviGrHzIbSc8+x9CpraDtbT7mfyjXObULP4w/adunNwAw==
142142
dependencies:
143143
"@babel/helper-compilation-targets" "^7.22.6"
144144
"@babel/helper-plugin-utils" "^7.22.5"
@@ -4989,9 +4989,9 @@
49894989
integrity sha512-t66jwrXA0s5Goq82ZtjagLNd7DPGCNjHeehRlE/gcJmJ+G56C0W+2plqOMRicJ8XGR1/YFnUSEqUFiSNbjGrAA==
49904990

49914991
"@substrate/connect-known-chains@^1.1.5":
4992-
version "1.9.2"
4993-
resolved "https://registry.npmjs.org/@substrate/connect-known-chains/-/connect-known-chains-1.9.2.tgz#9cbed20cf03091f28fc4319fe2419f735729ce52"
4994-
integrity sha512-uEmm+rKJQQhhbforvmcg74TsDHKFVBkstjPwblGT1RdHMxUKR7Gq7F8vbkGnr5ce9tMK2Ylil760Z7vtX013hw==
4992+
version "1.9.3"
4993+
resolved "https://registry.npmjs.org/@substrate/connect-known-chains/-/connect-known-chains-1.9.3.tgz#f6adbe74374f711ef1d624641555be7f28cbf4ad"
4994+
integrity sha512-CPcykiKcVuG4J424gNUFak4AdIJ1sXbu/Bk1IGVPOz74NlBO8EvUyRlpPA7IY0vEf7/n4HQ1gEN5lfgERo4q3w==
49954995

49964996
"@substrate/[email protected]":
49974997
version "0.8.11"
@@ -5198,11 +5198,6 @@
51985198
resolved "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.4.tgz#1a31c3d378850d2778dabb6374d036dcba4ba708"
51995199
integrity sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==
52005200

5201-
"@types/bluebird@^3.5.25":
5202-
version "3.5.42"
5203-
resolved "https://registry.npmjs.org/@types/bluebird/-/bluebird-3.5.42.tgz#7ec05f1ce9986d920313c1377a5662b1b563d366"
5204-
integrity sha512-Jhy+MWRlro6UjVi578V/4ZGNfeCOcNCp0YaFNIUGFKlImowqwb1O/22wDVk3FDGMLqxdpOV3qQHD5fPEH4hK6A==
5205-
52065201
"@types/bn.js@*", "@types/bn.js@^5.1.0", "@types/bn.js@^5.1.6":
52075202
version "5.1.6"
52085203
resolved "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.6.tgz#9ba818eec0c85e4d3c679518428afdf611d03203"
@@ -6913,12 +6908,12 @@ babel-loader@^9.1.0:
69136908
schema-utils "^4.0.0"
69146909

69156910
babel-plugin-polyfill-corejs2@^0.4.10:
6916-
version "0.4.12"
6917-
resolved "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.4.12.tgz#ca55bbec8ab0edeeef3d7b8ffd75322e210879a9"
6918-
integrity sha512-CPWT6BwvhrTO2d8QVorhTCQw9Y43zOu7G9HigcfxvepOU6b8o3tcWad6oVgZIsZCTt42FFv97aA7ZJsbM4+8og==
6911+
version "0.4.13"
6912+
resolved "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.4.13.tgz#7d445f0e0607ebc8fb6b01d7e8fb02069b91dd8b"
6913+
integrity sha512-3sX/eOms8kd3q2KZ6DAhKPc0dgm525Gqq5NtWKZ7QYYZEv57OQ54KtblzJzH1lQF/eQxO8KjWGIK9IPUJNus5g==
69196914
dependencies:
69206915
"@babel/compat-data" "^7.22.6"
6921-
"@babel/helper-define-polyfill-provider" "^0.6.3"
6916+
"@babel/helper-define-polyfill-provider" "^0.6.4"
69226917
semver "^6.3.1"
69236918

69246919
babel-plugin-polyfill-corejs3@^0.11.0:
@@ -6930,11 +6925,11 @@ babel-plugin-polyfill-corejs3@^0.11.0:
69306925
core-js-compat "^3.40.0"
69316926

69326927
babel-plugin-polyfill-regenerator@^0.6.1:
6933-
version "0.6.3"
6934-
resolved "https://registry.npmjs.org/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.6.3.tgz#abeb1f3f1c762eace37587f42548b08b57789bc8"
6935-
integrity sha512-LiWSbl4CRSIa5x/JAU6jZiG9eit9w6mz+yVMFwDE83LAWvt0AfGBoZ7HS/mkhrKuh2ZlzfVZYKoLjXdqw6Yt7Q==
6928+
version "0.6.4"
6929+
resolved "https://registry.npmjs.org/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.6.4.tgz#428c615d3c177292a22b4f93ed99e358d7906a9b"
6930+
integrity sha512-7gD3pRadPrbjhjLyxebmx/WrFYcuSjZ0XbdUujQMZ/fcE9oeewk2U/7PCvez84UeuK3oSjmPZ0Ch0dlupQvGzw==
69366931
dependencies:
6937-
"@babel/helper-define-polyfill-provider" "^0.6.3"
6932+
"@babel/helper-define-polyfill-provider" "^0.6.4"
69386933

69396934
"babel-plugin-styled-components@>= 1.12.0":
69406935
version "2.1.4"
@@ -14456,9 +14451,9 @@ [email protected]:
1445614451
integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==
1445714452

1445814453
"mime-db@>= 1.43.0 < 2":
14459-
version "1.53.0"
14460-
resolved "https://registry.npmjs.org/mime-db/-/mime-db-1.53.0.tgz#3cb63cd820fc29896d9d4e8c32ab4fcd74ccb447"
14461-
integrity sha512-oHlN/w+3MQ3rba9rqFr6V/ypF10LSkdwUysQL7GkXoTgIWeV+tcXGA852TBxH+gsh8UWoyhR1hKcoMJTuWflpg==
14454+
version "1.54.0"
14455+
resolved "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz#cddb3ee4f9c64530dff640236661d42cb6a314f5"
14456+
integrity sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==
1446214457

1446314458
mime-types@^2.1.12, mime-types@^2.1.16, mime-types@^2.1.25, mime-types@^2.1.27, mime-types@^2.1.31, mime-types@^2.1.35, mime-types@~2.1.17, mime-types@~2.1.19, mime-types@~2.1.24, mime-types@~2.1.34:
1446414459
version "2.1.35"
@@ -14924,9 +14919,9 @@ [email protected]:
1492414919
integrity sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw==
1492514920

1492614921
nanoid@^3.3.8:
14927-
version "3.3.10"
14928-
resolved "https://registry.npmjs.org/nanoid/-/nanoid-3.3.10.tgz#7bc882237698ef787d5cbba109e3b0168ba6e7b1"
14929-
integrity sha512-vSJJTG+t/dIKAUhUDw/dLdZ9s//5OxcHqLaDWWrW4Cdq7o6tdLIczUkMXt2MBNmk6sJRZBZRXVixs7URY1CmIg==
14922+
version "3.3.11"
14923+
resolved "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz#4f4f112cefbe303202f2199838128936266d185b"
14924+
integrity sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==
1493014925

1493114926
natural-compare@^1.4.0:
1493214927
version "1.4.0"

0 commit comments

Comments
 (0)