Registry / devops / express-grpc-transcoder

express-grpc-transcoder

JSON →
library0.4.0jsnpmunverified

Express middleware that transcodes JSON HTTP requests to gRPC and vice versa, similar to grpc-gateway but as a Node.js library. Current stable version is 0.4.0, with active development. It allows Express apps to serve a gRPC service via HTTP/1.1 JSON without an external proxy. Handles protocol buffer metadata, streaming, and error mapping. Differentiators: pure JavaScript, zero external proxy dependency, full TypeScript support, works with any gRPC service definition.

devops
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.

Package is ESM-only since v0.3.0. Default export removed.

import { transcode } from 'express-grpc-transcoder'

Helper function to load proto files. Returns a Promise with the proto definition.

import { loadProto } from 'express-grpc-transcoder'

MiddlewareOptions is a TypeScript type, not a value. Use type import to avoid bundling issues.

import type { MiddlewareOptions } from 'express-grpc-transcoder'

Sets up an Express server with gRPC-JSON transcoding middleware, loading a proto file and proxying requests to a gRPC backend.

import express from 'express'; import { transcode, loadProto } from 'express-grpc-transcoder'; import { credentials } from '@grpc/grpc-js'; async function start() { const app = express(); const proto = await loadProto('./path/to/service.proto'); const serviceUrl = process.env.GRPC_SERVICE_URL || 'localhost:50051'; app.use(express.json()); app.use('/api', transcode({ proto, service: 'myservice.MyService', url: serviceUrl, credentials: credentials.createInsecure() })); app.listen(3000, () => console.log('Listening on 3000')); } start();
Debug
Known footguns
breakingVersion 0.3.0 removed default export. Use named import { transcode } instead.
breakingVersion 0.3.0 dropped support for the deprecated `grpc` npm package. Requires `@grpc/grpc-js`.
deprecatedLegacy `grpc` package is deprecated and may cause security vulnerabilities.
gotchaProto files must be loaded fully before passing to transcode. loadProto returns a Promise.
gotchaThe middleware does not support unary-stream or stream-unary patterns; only unary-unary and stream-stream.
breakingVersion 0.2.0 changed response format from JSON object with 'output' key to direct response.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
9 hits · last 30 days
gptbot
3
ahrefsbot
1
Resources