Registry / devops / egg-obelisk

egg-obelisk

JSON →
library1.0.12jsnpmunverified

egg-obelisk is a gRPC framework for the Egg.js ecosystem, providing seamless integration of gRPC and Protobuf into Egg applications. Version 1.0.12 is the latest stable release, with a low update cadence. It extends Egg's router to support RPC methods, works with Egg middleware and plugins, and handles both HTTP and gRPC requests. Key differentiators include tight Egg integration, reuse of Egg's controller and service layers, and support for both HTTP and gRPC in a single app. It requires Node >=12 and uses egg-grpc under the hood.

npm install egg-obelisk
INSTALL
IMPORT
SIG · EGG-OBELISK
E
egg-obelisk
devopsjavascriptv1.0.12
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.

app.router.rpc
app.router.rpc('/path', controller.action)
app.router.rpc('/path', async (ctx) => {})
Use Egg-style controller, not inline handler.
egg-obelisk as framework
In package.json: { "egg": { "framework": "egg-obelisk" } }
Using egg-obelisk as a plugin instead of framework
Must set as framework in package.json, not just npm install.
config.obelisk
config.obelisk = { listen: { port: 50051 } }
config.obelisk = { port: 50051 }
listen.port, not port directly.

Complete example of setting up an Egg app with egg-obelisk as the framework, including router, controller, and service for a gRPC endpoint.

// package.json { "name": "my-grpc-app", "egg": { "framework": "egg-obelisk" }, "dependencies": { "egg-obelisk": "^1.0.0" } } // config/config.default.js config.obelisk = { listen: { port: 50051, hostname: '0.0.0.0', }, }; // app/router.js module.exports = app => { const { router, controller } = app; router.rpc('/user/login', controller.user.login); }; // app/controller/user.js const Controller = require('egg').Controller; class UserController extends Controller { async login() { this.ctx.body = await this.service.user.login(this.ctx.request.body); } } module.exports = UserController; // app/service/user.js const Service = require('egg').Service; class UserService extends Service { async login(params) { return { state: 'ok' }; } } module.exports = UserService; // start server $ npm start // test gRPC (assuming proto): client calls /user/login
Debug
Known issues
gotchaMust set egg.framework to 'egg-obelisk' in package.json, otherwise egg uses default framework and obelisk won't work.
fix
Add 'egg': { 'framework': 'egg-obelisk' } to package.json.
affects: all
gotchagRPC server listen.port is required in config.obelisk.listen, not config.obelisk.port.
fix
Use config.obelisk.listen = { port: 50051 }.
affects: all
gotchaController and service must be defined in EggJS style; direct arrow functions in router.rpc() will cause errors.
fix
Define controllers in app/controller and services in app/service, then reference them.
affects: all
deprecatedThis package has a low update cadence and may not support the latest Egg.js versions (>=3).
fix
Test compatibility with your Egg version; consider alternatives like grpc-alone if issues arise.
affects: >=1.0.0
Errors
Common errors & fixes
Error: listen EADDRINUSE :::50051
gRPC port 50051 already in use
fix
Change port in config.obelisk.listen.port.
Error: Cannot find module 'egg'
egg is not installed as a dependency
fix
Add 'egg' to your package.json dependencies and run npm install.
TypeError: router.rpc is not a function
egg-obelisk not set as framework, so router.rpc is undefined
fix
Ensure package.json has 'egg': { 'framework': 'egg-obelisk' }.
Error: schema file not found
Protobuf schema files are missing or misconfigured
fix
Place .proto files in app/proto directory and load them.
Upgrade
Version history
1.0.12latest on npm
Audit
Dependencies
eggrequiredegg-obelisk is an EggJS framework, requiring Egg.js core to run
Agent activity
4 hits · last 30 days
node
4
Resources
egg-obelisk — npm install egg-obelisk · libregistry