Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nice-grpc

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nice-grpc - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

12

lib/server/createErrorStatusObject.js

@@ -5,5 +5,6 @@ "use strict";

const grpc_js_1 = require("@grpc/grpc-js");
const abort_controller_x_1 = require("abort-controller-x");
const ServerError_1 = require("./ServerError");
/** @internal */
function createErrorStatusObject(error, trailer) {
function createErrorStatusObject(path, error, trailer) {
if (error instanceof ServerError_1.ServerError) {

@@ -16,4 +17,11 @@ return {

}
else if (abort_controller_x_1.isAbortError(error)) {
return {
code: grpc_js_1.status.CANCELLED,
details: 'The operation was cancelled',
metadata: trailer,
};
}
else {
// TODO: warning
process.emitWarning(`${path}: Uncaught error in server implementation method: ${error instanceof Error ? error.stack : error}`);
return {

@@ -20,0 +28,0 @@ code: grpc_js_1.status.UNKNOWN,

2

lib/server/handleBidiStreamingCall.js

@@ -51,3 +51,3 @@ "use strict";

}, err => {
call.destroy(createErrorStatusObject_1.createErrorStatusObject(err, context.trailer));
call.destroy(createErrorStatusObject_1.createErrorStatusObject(definition.path, err, context.trailer));
});

@@ -54,0 +54,0 @@ };

@@ -43,3 +43,3 @@ "use strict";

}, err => {
callback(createErrorStatusObject_1.createErrorStatusObject(err, context.trailer));
callback(createErrorStatusObject_1.createErrorStatusObject(definition.path, err, context.trailer));
});

@@ -46,0 +46,0 @@ };

@@ -50,3 +50,3 @@ "use strict";

}, err => {
call.destroy(createErrorStatusObject_1.createErrorStatusObject(err, context.trailer));
call.destroy(createErrorStatusObject_1.createErrorStatusObject(definition.path, err, context.trailer));
});

@@ -53,0 +53,0 @@ };

@@ -42,3 +42,3 @@ "use strict";

}, err => {
callback(createErrorStatusObject_1.createErrorStatusObject(err, context.trailer));
callback(createErrorStatusObject_1.createErrorStatusObject(definition.path, err, context.trailer));
});

@@ -45,0 +45,0 @@ };

{
"name": "nice-grpc",
"version": "0.1.0",
"version": "0.1.1",
"description": "A gRPC library that is nice to you",

@@ -27,3 +27,3 @@ "keywords": [

},
"author": "Daniel Lytkin <dan.lytkin@gmail.com>",
"author": "Daniel Lytkin <aikoven@deeplay.io>",
"license": "MIT",

@@ -30,0 +30,0 @@ "devDependencies": {

@@ -1,2 +0,2 @@

# nice-grpc
# nice-grpc [![npm version][npm-image]][npm-url]

@@ -44,5 +44,6 @@ A Node.js gRPC library that is nice to you. Built on top of

- Modern API that uses Promises and Async Iterables for streaming.
- Canceling client and server calls using
- Cancelling client and server calls using
[`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
- Client and server middleware via concise API that uses Async Generators.
- Client and server middleware support via concise API that uses Async
Generators.

@@ -52,3 +53,3 @@ ## Installation

```
npm install nice-grpc google-protobuf
npm install nice-grpc google-protobuf @grpc/grpc-js
npm install --save-dev @types/google-protobuf

@@ -818,3 +819,4 @@ ```

Support specifying timeouts for unary calls instead of absolute deadlines:
Add support for specifying timeouts for unary calls instead of absolute
deadlines:

@@ -869,1 +871,4 @@ ```ts

```
[npm-image]: https://badge.fury.io/js/nice-grpc.svg
[npm-url]: https://badge.fury.io/js/nice-grpc
import {Metadata, status, StatusObject} from '@grpc/grpc-js';
import {isAbortError} from 'abort-controller-x';
import {ServerError} from './ServerError';

@@ -6,2 +7,3 @@

export function createErrorStatusObject(
path: string,
error: unknown,

@@ -16,4 +18,15 @@ trailer: Metadata,

};
} else if (isAbortError(error)) {
return {
code: status.CANCELLED,
details: 'The operation was cancelled',
metadata: trailer,
};
} else {
// TODO: warning
process.emitWarning(
`${path}: Uncaught error in server implementation method: ${
error instanceof Error ? error.stack : error
}`,
);
return {

@@ -20,0 +33,0 @@ code: status.UNKNOWN,

@@ -77,3 +77,9 @@ import {handleBidiStreamingCall, MethodDefinition} from '@grpc/grpc-js';

err => {
call.destroy(createErrorStatusObject(err, context.trailer) as any);
call.destroy(
createErrorStatusObject(
definition.path,
err,
context.trailer,
) as any,
);
},

@@ -80,0 +86,0 @@ );

@@ -72,3 +72,5 @@ import {handleClientStreamingCall, MethodDefinition} from '@grpc/grpc-js';

err => {
callback(createErrorStatusObject(err, context.trailer));
callback(
createErrorStatusObject(definition.path, err, context.trailer),
);
},

@@ -75,0 +77,0 @@ );

@@ -76,3 +76,9 @@ import {handleServerStreamingCall, MethodDefinition} from '@grpc/grpc-js';

err => {
call.destroy(createErrorStatusObject(err, context.trailer) as any);
call.destroy(
createErrorStatusObject(
definition.path,
err,
context.trailer,
) as any,
);
},

@@ -79,0 +85,0 @@ );

@@ -14,6 +14,3 @@ import {handleUnaryCall, MethodDefinition} from '@grpc/grpc-js';

): handleUnaryCall<Request, Response> {
async function* unaryMethodHandler(
request: Request,
context: CallContext,
) {
async function* unaryMethodHandler(request: Request, context: CallContext) {
if (isAsyncIterable(request)) {

@@ -72,3 +69,5 @@ throw new Error(

err => {
callback(createErrorStatusObject(err, context.trailer));
callback(
createErrorStatusObject(definition.path, err, context.trailer),
);
},

@@ -75,0 +74,0 @@ );

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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