Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
grpc-express
Advanced tools
An Express middleware to reverse-proxy HTTP 1.1 REST requests into HTTP 2.0 gRPC requests and back.
You can use this middleware with NodeJS and Express to serve a gRPC backed service API to browsers. Focus of this middleware is ease of use and not performance. This middleware only supports Unary gRPC and server side streaming calls. As it is mentioned in gRPC-web protocol it's unlikely that bidrectional or client side streaming calls would be supported by browsers any time soon with pure REST endpoints.
Take a look at alternative methods of doing this:
.proto
modificationOn the other hand, Express middlewares are easy to use and the chance that your app already ships with Express is extremely high! Also it's NodeJS only and requires no additional setups in client or server side.
Begin by making a connection to a gRPC server in Node using official gRPC client for Node:
var PROTO_PATH = __dirname + '/path/to/some/service.proto';
var grpc = require('grpc');
var hello_proto = grpc.load(PROTO_PATH).helloworld;
var grpcClient = new hello_proto.Greeter('localhost:50051', grpc.credentials.createInsecure());
Then pass this already connected gRPC client to the middleware:
var grpcExpress = require('grpc-express');
var express = require('express');
var app = express();
// ...
app.use(grpcExpress(grpcClient));
Done! The middleware automatically registers REST endpoints and proxies requests to your gRPC server and back. If your service is in packageName
, and its name is serviceName
, you can access its methods over the following REST endpoints: http://expressServer/packageName/serviceName/[METHOD NAME]
.
Arguments are passed as JSON objects in. Unary calls return JSON objects back and streaming calls return a JSON array of objects back. For a more detailed and in-depth example of calling REST endpoints look at tests.
FAQs
gRPC express based web proxy
We found that grpc-express demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.