Registry / devops / egg-grpc-framework

egg-grpc-framework

JSON →
library1.0.14jsnpmunverified

gRPC framework for Egg.js (v1.0.14, last release unknown, low activity). Extends Egg.js with gRPC+Protobuf support, allows using Egg middleware and plugins with gRPC, supports both HTTP and gRPC requests sharing controllers and services. Alternative to manually setting up gRPC with Egg; uniquely integrates gRPC routing into Egg's router. Note: repository archived or unmaintained since 2019. Requires Node >=12.

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.

Egg uses CommonJS; ES imports are not supported in Egg's runtime.

const Controller = require('egg').Controller;

Same as Controller, must use require.

const Service = require('egg').Service;

router.rpc is a custom method provided by the framework; do not use standard HTTP methods for gRPC routes.

app.router.rpc('/user/login', controller.user.login);

Sets up an Egg.js project using egg-grpc-framework, configures gRPC server on port 50051, defines a gRPC route and a controller.

// package.json { "name": "my-grpc-app", "egg": { "framework": "egg-grpc-framework" }, "dependencies": { "egg-grpc-framework": "^1.0.0" } } // config/config.default.js config.gRPC = { listen: { port: 50051, hostname: '0.0.0.0', }, }; // app/router.js 'use strict'; module.exports = app => { const { router, controller } = app; router.rpc('/user/login', controller.user.login); }; // app/controller/user.js 'use strict'; const Controller = require('egg').Controller; class UserController extends Controller { async login() { const body = this.ctx.request.body; this.ctx.body = { state: 'ok' }; } } module.exports = UserController;
Debug
Known footguns
gotchaThe package is archived on GitHub; no maintenance or updates since 2019. Use with caution.
breakingUsing 'egg-grpc-framework' as framework overrides Egg's default behavior; may conflict with other Egg plugins.
deprecatedThe package does not use ESM; CommonJS only. Node 12+ may still support require, but future Egg versions might drop CommonJS support.
gotcharouter.rpc expects a gRPC method definition from .proto files; if proto files are missing or misconfigured, the route will silently fail.
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