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

connect-proxy-layer

v0.1.2

Published

Connect middleware to proxy (and optionally transform) requests to a different server

Downloads

3

Readme

ConnectProxyLayer

Connect proxy layer is a piece of connect middleware that allows you to send requests on to another end server. Additionally, you can define functions for the proxy to use to modify the request in-flight. If you do not specify interceptors the proxy will simply pipe data from the input, and proxy the response.

Usage

Using connect-proxy-layer is as simple as:

var cpl = require('connect-proxy-layer'), connect = require('connect');

var app = connect();

app.use("/api", cpl("http://api.example.com/"));

app.listen(80);

Using Interceptors

####Header The header interceptor allows you to determine whether the requests needs additional transformation based upon information available in the headers and URL of the request.

function header(localRequest, next, proxy, pump)
  • localRequest - The http.incomingRequest that the server recieved. Use this to read headers and URL information.
  • next - The connect "next" object, used to skip this route and continue the connect chain.
  • proxy - A function that takes no arguments, telling the server to "proxy" the request to allow for request modifications.
  • pump - A function that takes no arguments, telling the server to pump the request directly into the remote connection.

####Input The input interceptor is what is called to transform "Proxied" requests to the server.

function input(localRequest, requestBody, localResponse, next, proxy)
  • localRequest - The http.incomingRequest that the server recieved. Use this to read headers and URL information.
  • requestBody - The string that was sent to the proxy server.
  • localResponse - The http.outgoingMessage that is to be sent to the client.
  • next - The connect "next" object, used to skip this route and continue the connect chain.
  • proxy - A function that will execute the request to the server, this must be called like.
proxy(localRequest, requestBody, localResponse, nxt);

####Output The output interceptor is called to modify response data from the server before it is sent to the client.

function output(remoteResponse, responseBody, localResponse, next, send)
  • remoteResponse - The http.incomingMessage from the remote server.
  • responseBody - The response string sent by the remote server.
  • localResponse - The http.outgoingMessage that is to be sent to the client.
  • next - The connect "next" object, used to skip this route and continue the connect chain.
  • send - A function that will send the response to the client, and must be called like
send(localResponse, remoteResponse, responseBody);

###NB To use the "input" interceptor you must define a header interceptor and call proxy(), because the default behavior is to pump the request.

License

This software is provided under a BSD 2-Clause license.