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

@ddadaal/tsgrpc-server

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ddadaal/tsgrpc-server - npm Package Compare versions

Comparing version 0.1.8 to 0.2.0

16

CHANGELOG.md

@@ -6,2 +6,18 @@ # Change Log

# [0.2.0](https://github.com/ddadaal/tsgrpc/compare/v0.1.8...v0.2.0) (2021-10-22)
### Bug Fixes
* add tslib ([8039e34](https://github.com/ddadaal/tsgrpc/commit/8039e3480d9c211c1e9cbe1dd2577589cd08292d))
### Features
* **server:** add logger to server handler ([81ad7df](https://github.com/ddadaal/tsgrpc/commit/81ad7df11b7cf1545596c5857322d76d3af6e5d2))
## [0.1.8](https://github.com/ddadaal/tsgrpc/compare/v0.1.7...v0.1.8) (2021-10-21)

@@ -8,0 +24,0 @@

14

dist/server.d.ts

@@ -10,2 +10,13 @@ import * as grpc from "@grpc/grpc-js";

}
declare type Rest<T extends any[]> = T extends [infer _I, ...infer L] ? L : never;
export declare type ResponseType<T extends (...args: any[]) => void> = Rest<Parameters<Parameters<T>[1]>>;
export declare type Call<TOrig> = TOrig & {
logger: Logger;
};
declare type RemoveIndex<T> = {
[K in keyof T as string extends K ? never : number extends K ? never : K]: T[K];
};
export declare type TPromisifiedImplementation<TImpl extends grpc.UntypedServiceImplementation> = {
[K in keyof RemoveIndex<TImpl>]: (call: Call<Parameters<RemoveIndex<TImpl>[K]>[0]>, ...rest: Rest<Parameters<RemoveIndex<TImpl>[K]>>) => (void | Promise<void | ResponseType<RemoveIndex<TImpl>[K]>>);
};
export declare type Plugin = (server: Server) => (void | Promise<void>);

@@ -23,3 +34,3 @@ /** Helper identify function to build plugin. */

addCloseHook: (hook: CloseCallback) => void;
addService: <TImpl extends grpc.UntypedServiceImplementation>(server: grpc.ServiceDefinition<TImpl>, impl: TImpl) => void;
addService: <TImpl extends grpc.UntypedServiceImplementation>(server: grpc.ServiceDefinition<TImpl>, impl: TPromisifiedImplementation<TImpl>) => void;
addPlugin: (key: PropertyKey, value: any) => void;

@@ -31,1 +42,2 @@ close: () => Promise<void>;

}
export {};

@@ -28,7 +28,20 @@ "use strict";

addService = (server, impl) => {
const actualImpl = {};
for (const key in impl) {
// @ts-ignore
impl[key] = (0, tsgrpc_utils_1.unpromisify)(impl[key]);
actualImpl[key] = (call, callback) => {
// logger
const reqId = new Date().toISOString();
const logger = (0, tsgrpc_utils_1.getLogger)(`req-${reqId}`);
logger.trace(`Starting serving req-${reqId}`);
// @ts-ignore
const ret = impl[key]({ ...call, logger }, callback);
if (ret && callback) {
ret.then((x) => { if (x) {
callback(null, ...x);
} });
}
};
}
this.server.addService(server, impl);
this.server.addService(server, actualImpl);
};

@@ -35,0 +48,0 @@ addPlugin = (key, value) => {

9

package.json
{
"name": "@ddadaal/tsgrpc-server",
"version": "0.1.8",
"version": "0.2.0",
"description": "A simple gRPC Server Framework for TypeScript Node.js",

@@ -21,4 +21,5 @@ "main": "./dist/index.js",

"dependencies": {
"@ddadaal/tsgrpc-utils": "^0.1.8",
"@grpc/grpc-js": "^1.4.1"
"@ddadaal/tsgrpc-utils": "^0.2.0",
"@grpc/grpc-js": "^1.4.1",
"tslib": "^2.3.1"
},

@@ -38,3 +39,3 @@ "devDependencies": {

},
"gitHead": "c24c06f52b3f8bb63637196b089c031051c3a12b"
"gitHead": "6dcd3fed93c7c3c5f8fc52685bb1d45a05d4b125"
}

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