npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

gaea

v6.0.0

Published

The manager to wrap grpc services and hold .proto files.

Readme

Build Status Coverage

gaea

The manager to wrap grpc services and hold .proto files.

  • Handle Custom Errors gRPC does NOT provide an formal way to handle errors, even lack of documentation, while gaea will do it for you.
  • Manage .proto files gaea allows us to share proto files between server and clients. gaea shares gPRC protobuf files by wrapping them into an npm package and publishing the npm tarball to npm registry.
  • Eggjs compatible plugins gaea supports to use egg plugins to extend your applications.
  • Restful API service made easy gaea provides a convenient way to define restful API routings upon the existing gRPC services.

Install

$ npm i gaea

APIs

const {
  Server, Client
} = require('gaea')

const root = path.join(__dirname, 'example')

To make better understanding the usage of gaea, the example below is based on the demo in the example/hello directory.

Start server:

new Server(root).listen(50051)

Run client:

const {
  // service Greeter
  Greeter
} = new Client(root).connect('localhost:50051')

const run = async () => {
  const {message} = await Greeter.sayHello({name: 'world'})

  console.log(message)
}

run()
// Hello world

APIs

new Client(root, clientConfig?)

Creates the gaea client.

  • root path the root path to load the client from
  • clientConfig? BaseConfig client configuration. If not specified, gaea will load configuration from ${root}/config.js
interface BaseConfig {
  // Tells `gaea` which properties of error should be
  // - collected, serialized and transmitted to the clients.
  // - or deseriialized from server
  // `error_props` defaults to `['code', 'message']`
  error_props: Array<string>
  // specifies where to load proto files.
  proto_root: string
  // Proto filenames inside `proto_root`.
  // If not specified, gaea will use all `.proto` files inside `proto_root`.
  protos?: Array<string>
}

client.connect(host):

Connects to the gRPC server and returns the service methods

  • host string the server host to connect to which includes the server hostname and port and whose pattern is <hostname>:<port>

new Server(root, serverConfig?)

  • root path the root path to load the server from
  • serverConfig? ServerConfig server configurations. If not specified, gaea will load configuration from ${root}/config.js
interface ServerConfig extends BaseConfig {
  plugins: Array<Plugin>
  services: Services
}

interface Package {
  // The root path of the package
  path?: string
  // The package name of the package
  package?: string

  // Either path or package should be defined.
}

interface Plugin extends Package {
  // Configurations for the plugin
  config: object
}

interface Service extends Package {
  // the host param of `client.connect(host)`
  host: string
}

interface Services {
  [name: string]: Service
}
const g = gaea({
  // if the server throws an `error`, gaea will collect
  // - `error.code`,
  // - `error.message`
  // - `error.stack`,
  // and send them to its clients, while other properties will be omitted.
  error_props: ['code', 'message', 'stack'],
  proto_root: '/path/to/example/proto'

  // and read all .proto files
})

server.listen(port): void

  • port number the port which gRPC server will listen to.

Start the gaea server.

License

MIT

If we have a foo package in a proto file, and inside the foo package there is a Bar service, then we must put a foo/Bar.js file in /path/to/example/service/.

And if there is a Baz rpc method in the Bar service, we must set a Baz function as one of the exports of the foo/Bar.js. The Baz function might have one argument(or no arguments) which accepts the data from the client.

Or there will be errors.

Besides, if there is a Quux service which not in any package, we should just put a Quux.js file in /path/to/example/service/.