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.

npm install egg-grpc-framework
INSTALL
IMPORT
SIG · EGG-GRPC-FRAMEWORK
E
egg-grpc-framework
devopsjavascriptv1.0.14
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.

Controller
const Controller = require('egg').Controller;
import { Controller } from 'egg';
Egg uses CommonJS; ES imports are not supported in Egg's runtime.
Service
const Service = require('egg').Service;
import { Service } from 'egg';
Same as Controller, must use require.
router.rpc
app.router.rpc('/user/login', controller.user.login);
app.router.post('/user/login', controller.user.login);
router.rpc is a custom method provided by the framework; do not use standard HTTP methods for gRPC routes.

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 issues
gotchaThe package is archived on GitHub; no maintenance or updates since 2019. Use with caution.
fix
Consider alternative like manually integrating @grpc/grpc-js with Egg.
affects: all
breakingUsing 'egg-grpc-framework' as framework overrides Egg's default behavior; may conflict with other Egg plugins.
fix
Ensure no other framework is set; test thoroughly.
affects: >=1.0.0
deprecatedThe package does not use ESM; CommonJS only. Node 12+ may still support require, but future Egg versions might drop CommonJS support.
fix
Stick with CommonJS require for now.
affects: all
gotcharouter.rpc expects a gRPC method definition from .proto files; if proto files are missing or misconfigured, the route will silently fail.
fix
Ensure .proto files are placed in app/proto/ and loaded correctly.
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'egg-grpc-framework'
Missing dependency or incorrect framework path in package.json.
fix
Run 'npm install egg-grpc-framework --save' and ensure package.json has 'egg': { 'framework': 'egg-grpc-framework' }.
TypeError: app.router.rpc is not a function
Framework not set correctly in package.json or Egg not picking it up.
fix
Verify package.json has the egg.framework field, and that egg-grpc-framework is installed.
Error: listen EADDRINUSE :::50051
Port 50051 already in use by another process.
fix
Change gRPC port in config/config.default.js or kill the process using the port.
Upgrade
Version history
1.0.14latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
egg-grpc-framework — npm install egg-grpc-framework · libregistry