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 🙏

© 2024 – Pkg Stats / Ryan Hefner

warpfield

v0.0.3

Published

An RPC framework that leverages protocol buffers to make server to server communication fast.

Downloads

8

Readme

warpfield

NPM version Dependency Status Dev Dependency Status Code Climate Build Status Coverage Status

An RPC framework that leverages protocol buffers to make server to server communication fast.

Installation

npm install --save warpfield

Usage

server usage

// greeter.proto
message Request {
  string name = 1;
}

message Response {
  string message = 1;
}

service Greeter {
  rpc SayHello (Request) returns (Response);
}
'use strict'

const warpfield = require('warpfield')

const proto = warpfield.loadFile('greeter.proto')
const server = warpfield.server()

const greeter = warpfield.service(proto.Greeter, {
  sayHello(request) {
    return { message: `Hello ${request.name}` }
  }
})

server.use(greeter)

server.listen({ port: '8000' })

client usage

const warpfield = require('warpfield')

const proto = warpfield.loadFile('greeter.proto')
const greeter = warpfield.client(proto.Greeter, {
  host: 'http://localhost:8000'
})

greeter.sayHello({ name: 'Jack Bliss' })
  .then((response) => {
    console.log('Greeting:', response.message)
  })

API

warpfield is heretofore a shortcut for `require('warpfield') as far as these docs are concerned.

warpfield.loadFile(path)

Loads a .proto file. Services will be on the returned object with the service names being the properties.

  • path The path to the proto file to load. This path must be relative to cwd or an absolute path. Protocol buffer imports are not resolved at this time.

warpfield.load(protobuf)

Loads the protocol buffer schema from a string/buffer. Services will be on the returned object with the service names being the properties.

  • protobuf A string/buffer of the protocol buffer definition.

warpfield.service(protobufService[, handlers])

Returns a warpfield service object

  • protobufService The protocol buffer service as returned from .load or .loadFile. If it's not passed, it's assumed that this will be a json service, rather than a protocol buffer service.
  • handlers An object who's keys correspond with the method names of the service. The keys must be the lowerCamelCase version of their schema counterparts (if a protobuf service is passed). The values must be functions. Those functions can return promises so long as the promises resolve to an object the match the definition. Handlers can be added after this initial declaration.

service.handle(methodName, handler)

Adds a handler to a given method name.

  • methodName The name of the method to bind to.
  • handler The function that should be called when the method is called.

warpfield.server()

Returns a new warpfield server instance

server.use(service)

Registers a service with the server

  • service The warpfield service instance to bind to that namespace.

server.listen(options)

Starts the server. Returns a promise that resolves when the server has started.

  • options.type The type of transport to use. 'http' is the only valid one for now. Defaults to 'http'
  • options.* the rest of the options will vary depending on the transport.

server.close()

Stops the server. Returns a promise that resolves when the server has closed.

warpfield.client(protobufService, remoteOptions)

Returns a new warpfield client with the methods on the given service. It will have the methods of the service in lowerCamelCase form.

  • protobufService The protobufService instance from warpfield.load[File].
  • remoteOptions This can be an object or a warpfield service.
  • remoteOptions.type The type of transport to use. 'http' is the only valid one for now. Defaults to 'http'
  • remoteOptions.* The rest of the options will vary depending on the transport.