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.15 to 0.2.0

lib/logging.js

2

lib/handler.js
'use strict';
const EventEmitter = require('events');
const { Duplex, Readable, Writable } = require('stream');
const { status: Status } = require('@grpc/grpc-js');
const Status = require('./status');
const { StreamDecoder } = require('./stream-decoder');

@@ -6,0 +6,0 @@ const kCall = Symbol('call');

@@ -78,2 +78,12 @@ /// <reference types="node" />

export declare enum LogVerbosity {
DEBUG = 0,
INFO = 1,
ERROR = 2
}
export declare const setLogger: (logger: Partial<Console>) => void;
export declare const setLogVerbosity: (verbosity: LogVerbosity) => void;
export declare enum Status {

@@ -193,1 +203,6 @@ OK = 0,

}
export {
LogVerbosity as logVerbosity,
Status as status
};
'use strict';
const { ServerCredentials } = require('@grpc/grpc-js');
const { LogVerbosity, setLogger, setLogVerbosity } = require('./logging');
const { Metadata } = require('./metadata');
const { Server } = require('./server');
const { ServerCredentials } = require('./server-credentials');
const Status = require('./status');
module.exports = { Server, ServerCredentials };
module.exports = {
logVerbosity: { ...LogVerbosity },
Metadata,
Server,
ServerCredentials,
setLogger,
setLogVerbosity,
status: { ...Status }
};
'use strict';
const EventEmitter = require('events');
const Http2 = require('http2');
const { Metadata, status: Status } = require('@grpc/grpc-js');
const { CompressionFilter } = require('./compression-filter');
const { Metadata } = require('./metadata');
const Status = require('./status');
const kGrpcMessageHeader = 'grpc-message';

@@ -7,0 +8,0 @@ const kGrpcStatusHeader = 'grpc-status';

'use strict';
const Http2 = require('http2');
const { status, ServerCredentials } = require('@grpc/grpc-js');
const {

@@ -11,4 +10,6 @@ ServerDuplexStream,

const { ServerCall } = require('./server-call');
const { ServerCredentials } = require('./server-credentials');
const { resolveToListenOptions } = require('./server-resolver');
const { ServerSession } = require('./server-session');
const Status = require('./status');
const kHandlers = Symbol('handlers');

@@ -33,7 +34,2 @@ const kServer = Symbol('server');

const unimplementedStatusResponse = {
code: status.UNIMPLEMENTED,
details: 'The server does not implement this method'
};
const unsuportedMediaTypeResponse = {

@@ -44,17 +40,2 @@ [HTTP2_HEADER_STATUS]: HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE

const defaultHandler = [
function unary (call, callback) {
callback(unimplementedStatusResponse);
},
function clientStream (call, callback) {
callback(unimplementedStatusResponse);
},
function serverStream (call) {
call.emit('error', unimplementedStatusResponse);
},
function bidi (call) {
call.emit('error', unimplementedStatusResponse);
}
];
function noop () {}

@@ -219,3 +200,3 @@

} else {
impl = defaultHandler[methodType];
impl = getDefaultHandler(methodType, name);
}

@@ -336,3 +317,3 @@

if (handler === undefined) {
return call.sendError(unimplementedStatusResponse);
return call.sendError(getUnimplementedStatusResponse(path));
}

@@ -345,3 +326,3 @@

} catch (err) {
call.sendError(err, status.INTERNAL);
call.sendError(err, Status.INTERNAL);
}

@@ -423,1 +404,35 @@ });

}
function getUnimplementedStatusResponse (path) {
return {
code: Status.UNIMPLEMENTED,
details: `The server does not implement the method ${path}`
};
}
function getDefaultHandler (handlerType, callName) {
const unimplementedStatusResponse = getUnimplementedStatusResponse(callName);
switch (handlerType) {
case 0 : // Unary
return function unary (call, callback) {
callback(unimplementedStatusResponse);
};
case 1 : // Client stream
return function clientStream (call, callback) {
callback(unimplementedStatusResponse);
};
case 2 : // Server stream
return function serverStream (call) {
call.emit('error', unimplementedStatusResponse);
};
case 3 : // Bidi stream
return function bidi (call) {
call.emit('error', unimplementedStatusResponse);
};
default :
throw new Error(`Invalid handler type ${handlerType}`);
}
}
{
"name": "grpc-server-js",
"version": "0.1.15",
"version": "0.2.0",
"description": "Pure JavaScript gRPC Server",

@@ -25,6 +25,4 @@ "author": "Colin J. Ihrig <cjihrig@gmail.com> (http://www.cjihrig.com/)",

},
"dependencies": {
"@grpc/grpc-js": "^0.6.12"
},
"devDependencies": {
"@grpc/grpc-js": "^0.6.17",
"@grpc/proto-loader": "0.5.x",

@@ -31,0 +29,0 @@ "belly-button": "6.x.x",

@@ -16,9 +16,12 @@ # grpc-server-js

- Unary calls.
- Streaming client request calls.
- Streaming server response calls.
- Bidirectional streaming calls.
- [Unary calls](https://grpc.github.io/grpc/node/grpc-ServerUnaryCall.html).
- [Streaming client request calls](https://grpc.github.io/grpc/node/grpc-ServerReadableStream.html).
- [Streaming server response calls](https://grpc.github.io/grpc/node/grpc-ServerWritableStream.html).
- [Bidirectional streaming calls](https://grpc.github.io/grpc/node/grpc-ServerDuplexStream.html).
- Deadline and cancellation support.
- Support for gzip and deflate compression, as well as uncompressed messages.
- The only third party dependency is [`@grpc/grpc-js`](https://www.npmjs.com/package/@grpc/grpc-js), which is used for some shared data structures.
- [Server credentials](https://grpc.github.io/grpc/node/grpc.ServerCredentials.html) for handling both secure and insecure calls.
- [gRPC Metadata](https://grpc.github.io/grpc/node/grpc.Metadata.html).
- gRPC logging.
- No production dependencies.
- No C++ dependencies. This implementation relies on Node's [`http2`](https://nodejs.org/api/http2.html) module.

@@ -31,2 +34,7 @@ - Supports the following gRPC server options:

- All possible options and their descriptions are available [here](https://github.com/grpc/grpc/blob/master/include/grpc/impl/codegen/grpc_types.h).
- Supports the following gRPC environment variables:
- `GRPC_DEFAULT_SSL_ROOTS_FILE_PATH`
- `GRPC_SSL_CIPHER_SUITES`
- `GRPC_VERBOSITY`
- All possible environment variables and their descriptions are available [here](https://github.com/grpc/grpc/blob/master/doc/environment_variables.md).

@@ -33,0 +41,0 @@ ## Public API Deviations from the Existing `grpc.Server`

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