Registry / devops / rest2grpc

rest2grpc

JSON →
library0.3.3jsnpmunverified

A library (v0.3.3, pre-1.0) for converting HTTP REST requests into gRPC calls at runtime, enabling gradual migration from REST to gRPC without rewriting clients. Unlike code-generation tools (e.g., grpc-gateway), it uses dynamic proto reflection to translate REST endpoints to gRPC methods on the fly. Low release cadence, experimental. Ships TypeScript types.

npm install rest2grpc
INSTALL
IMPORT
SIG · REST2GRPC
R
rest2grpc
devopsjavascriptv0.3.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import rest2grpc from 'rest2grpc'
const rest2grpc = require('rest2grpc').default
Package is ESM-only; default export is the main factory.
Rest2GrpcOptions
import { Rest2GrpcOptions } from 'rest2grpc'
import { Rest2GrpcOptions } from 'rest2grpc/options'
Type is exported from the main module as a named export.
CallOptions
import { CallOptions } from 'rest2grpc'
Named export for configuring individual RPC calls.

Shows initializing rest2grpc with proto files and converting a REST request to a gRPC call.

import rest2grpc from 'rest2grpc'; import path from 'path'; const protoDir = path.join(__dirname, 'protos'); const converter = await rest2grpc({ protoDir, protoFiles: ['greet.proto'], address: process.env.GRPC_ADDRESS ?? 'localhost:50051', }); // Convert a REST-like request to a gRPC call const restRequest = { method: 'POST', path: '/greet.v1.Greeter/SayHello', body: { name: 'World' }, }; const grpcResponse = await converter(restRequest); console.log(grpcResponse); // { message: 'Hello World' }
Debug
Known issues
breakingPre-1.0 semver: no stability guarantees, API may change between patch versions.
fix
Pin exact version and test upgrades.
affects: >=0.0.0
deprecatedUsage of require() may fail due to ESM-only distribution.
fix
Use import syntax or enable ESM in your project.
affects: >=0.3.0
gotchaProto reflection requires proto files accessible at runtime; must be bundled or hosted on disk.
fix
Ensure protoDir points to a directory containing the .proto files referenced in protoFiles.
affects: >=0.1.0
breakingOptions interface Rest2GrpcOptions changed between 0.2.x and 0.3.x: 'protoFiles' renamed from 'files'.
fix
Use 'protoFiles' instead of 'files' in the options object.
affects: >=0.2.0 <0.3.0
gotchaThe converter function returns a Promise that may throw gRPC errors with non-standard shape; error handling may break.
fix
Wrap in try/catch and inspect error.code and error.details.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: (0 , rest2grpc_1.default) is not a function
Using require() instead of import in an ESM-only package.
fix
Replace require('rest2grpc') with import rest2grpc from 'rest2grpc'.
Error: ENOENT: no such file or directory, open '/path/to/greet.proto'
protoDir or protoFiles path does not exist or is relative incorrectly.
fix
Use absolute paths via path.resolve() or __dirname.
Error: 12 UNIMPLEMENTED: Method not found
The REST path does not match any gRPC method defined in the loaded protos.
fix
Verify the path format matches '<package>.<service>/<method>' exactly as in proto definition.
TypeError: Cannot read properties of undefined (reading 'call')
converter invoked before initialization promise resolved.
fix
Ensure await rest2grpc(...) completes before using the converter function.
Upgrade
Version history
0.3.3latest on npm
Audit
Dependencies
@grpc/grpc-jsrequiredRuntime gRPC client
protobufjsrequiredProto reflection and serialization
Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources
rest2grpc — npm install rest2grpc · libregistry