Socket
Socket
Sign inDemoInstall

grpc-server-js

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grpc-server-js - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

lib/index.d.ts

65

lib/server.js

@@ -59,2 +59,6 @@ 'use strict';

if (typeof port === 'number') {
port = `localhost:${port}`;
}
if (creds === null || typeof creds !== 'object') {

@@ -64,7 +68,33 @@ creds = ServerCredentials.createInsecure();

if (typeof port === 'string') {
const url = new URL(`http://${port}`);
port = { host: url.hostname, port: url.port };
return new Promise((resolve, reject) => {
this.bindAsync(port, creds, (err, boundPort) => {
if (err) {
reject(err);
}
resolve(boundPort);
});
});
}
bindAsync (port, creds, callback) {
if (this[kStarted] === true) {
throw new Error('server is already started');
}
if (typeof port !== 'string') {
throw new TypeError('port must be a string');
}
if (creds === null || typeof creds !== 'object') {
throw new TypeError('creds must be an object');
}
if (typeof callback !== 'function') {
throw new TypeError('callback must be a function');
}
const url = new URL(`http://${port}`);
const options = { host: url.hostname, port: +url.port };
if (creds._isSecure()) {

@@ -78,11 +108,14 @@ this[kServer] = Http2.createSecureServer(creds._getSettings());

this[kServer].on('error', (err) => {
// TODO: What to do here?
throw err;
});
function onError (err) {
this[kServer] = null;
callback(err, -1);
}
return new Promise((resolve, reject) => {
this[kServer].listen(port, () => {
resolve(this[kServer].address().port);
});
this[kServer].once('error', onError);
this[kServer].listen(options, () => {
const server = this[kServer];
const port = server.address().port;
server.removeListener('error', onError);
callback(null, port);
});

@@ -178,5 +211,13 @@ }

forceShutdown () { // eslint-disable-line class-methods-use-this
forceShutdown () { // eslint-disable-line class-methods-use-this
throw new Error('not implemented');
}
addHttp2Port () { // eslint-disable-line class-methods-use-this
throw new Error('not implemented');
}
addProtoService () { // eslint-disable-line class-methods-use-this
throw new Error('not implemented. use addService() instead');
}
}

@@ -183,0 +224,0 @@

5

package.json
{
"name": "grpc-server-js",
"version": "0.1.0",
"version": "0.1.1",
"description": "Pure JavaScript gRPC Server",
"author": "Colin J. Ihrig <cjihrig@gmail.com> (http://www.cjihrig.com/)",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"homepage": "https://github.com/cjihrig/grpc-server-js",

@@ -31,3 +32,3 @@ "repository": {

"cb-barrier": "1.x.x",
"lab": "18.x.x"
"@hapi/lab": "18.x.x"
},

@@ -34,0 +35,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc