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

node-relay

v1.0.4

Published

A relay that proxies http servers across nats.

Downloads

9

Readme

node-relay

Build Status

An http relay that proxies http requests using socket.io to signal clients that forward the request and push the results back to the relay.

heroku deploy

Deploy

install

with npm do:

$ npm install -g node-relay

usage

Default environment variables for configuration:

  • RELAY_TOKEN - for both client and server.
    • token to secure server.
    • token for client to access server.
  • RELAY_SERVER - web address of relay server.
  • PORT - port for server to bind to; default is 3000.

NOTE: command line parameters will overwrite environment variable configuration.

start

Start a relay server.

$ relay start [opts]

Options:

  • --token='<tokenstring>' - token to use for securing server.
  • --port=<number> - port for server to bind to; default is 3000.

share

Share a directory through a relay server. Spins up a basic serve-static server and proxies it through the relay.

$ relay share [opts] <dir>

NOTE: <dir> can be relative or absolute.

Options:

  • --token='<tokenstring>' - token to use for connecting to relay server.
  • --relay='<relayaddr>' - web address of relay server.

proxy

Proxy local server through a relay.

$ relay proxy <addr>

Options:

  • --token='<tokenstring>' - token to use for connecting to relay server.
  • --relay='<relayaddr>' - web address of relay server.

ping

Check if relay server is up; should respond with pong. Will default to RELAY_SERVER if addr is not specified.

$ relay ping <addr>

api

Relaying https://www.npmjs.com to http://localhost:3000.

For the server do:

var server = require('node-relay').server;
server.start({
  port: 3000,
  token: 'randomstring'
});

For the client do:

var client = require('node-relay').client;
client.connect({
  server 'https://www.npmjs.com',
  relay: 'http://localhost:3000',
  token: 'randomstring'
});

the magic

  • http request comes into the relay-server
  • relay-server notifies relay-client about request using socket.io connection
  • relay-client starts http request to application server
  • relay-client pulls request body from relay-server and streams it to application server
  • relay-client pushes application server response headers/body to relay-server.
  • relay-server responds to http request with pushed info

So a single http request turns into three requests.

test

To run all the tests, do:

$ npm test