Skip to content

Commit

Permalink
fix: avoid experimental warning of http2 (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
gxcsoccer authored Oct 12, 2018
1 parent d5eed77 commit 62d3b14
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 4 deletions.
16 changes: 14 additions & 2 deletions lib/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,17 @@ exports.RpcConsumer = require('./consumer');
exports.RpcConnection = require('./connection/rpc');
exports.RpcConnectionMgr = require('./connection_mgr');
exports.DynamicConfig = require('./dynamic_config');
exports.GRpcClient = require('./grpc_client');
exports.GRpcConnection = require('./connection/grpc');

// avoid stderr "ExperimentalWarning: The http2 module is an experimental API."
Object.defineProperty(exports, 'GRpcClient', {
get() {
return require('./grpc_client');
},
enumerable: true,
});
Object.defineProperty(exports, 'GRpcConnection', {
get() {
return require('./connection/grpc');
},
enumerable: true,
});
9 changes: 8 additions & 1 deletion lib/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@ exports.RpcServer = require('./server');
exports.RpcService = require('./service');
exports.RpcResponse = require('./response');
exports.RpcConnection = require('./connection');
exports.GRpcServer = require('./grpc/server');

// avoid stderr "ExperimentalWarning: The http2 module is an experimental API."
Object.defineProperty(exports, 'GRpcServer', {
get() {
return require('./grpc/server');
},
enumerable: true,
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"await-first": "^1.0.0",
"byte": "^2.0.0",
"cluster-client": "^2.1.1",
"debug": "^4.0.1",
"debug": "^4.1.0",
"easy-table": "^1.1.1",
"graceful": "^1.0.1",
"is-type-of": "^1.2.1",
Expand Down
14 changes: 14 additions & 0 deletions test/client/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

const path = require('path');
const coffee = require('coffee');

describe('test/client/index.test.js', () => {
it('should not have stderr', done => {
coffee.fork(path.join(__dirname, 'require.js'), [])
.expect('stdout', 'hello world\n')
.expect('stderr', '')
.expect('code', 0)
.end(done);
});
});
5 changes: 5 additions & 0 deletions test/client/require.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

require('../..');

console.log('hello world');

0 comments on commit 62d3b14

Please sign in to comment.