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

fimiproxy

v0.1.8

Published

Simple HTTP and HTTPS reverse proxy

Downloads

104

Readme

fimiproxy

simple HTTP | HTTPS reverse proxy in node.js. currently supports:

installation

  • for global installation npm i fimiproxy -g
  • for local installation npm i fimiproxy
  • for local dev-dependency installation npm i fimiproxy -D

replace npm with yarn or any other package manager of choice.

configuration

{
  "exposeHttpProxy": false,
  "exposeHttpsProxy": false,
  "httpPort": "",
  "httpsPort": "",
  "httpsPublicKeyFilepath": "",
  "httpsPrivateKeyFilepath": "",
  "httpsPublicKey": "",
  "httpsPrivateKey": "",
  "routes": [
    {
      "originHost": "",
      "originPort": "",
      "originProtocol": "http:",
      "incomingHostAndPort": ""
    }
  ]
}
  • exposeHttpProxy — set to true to expose an HTTP server, requires httpPort to be set if true
  • exposeHttpsProxy — set to true to expose an HTTPS server, requires httpsPort, httpsPublicKey OR httpsPublicKeyFilepath, httpsPrivateKey OR httpsPrivateKeyFilepath to be set if true
  • httpPort — port HTTP server should listen on, when exposeHttpProxy is true
  • httpsPort — port HTTPS server should listen on, when exposeHttpsProxy is true
  • httpsPublicKeyFilepath — filepath to TLS certificate (public key) used with HTTPS server
  • httpsPrivateKeyFilepath — filepath to TLS private key used with HTTPS server
  • httpsPublicKey — TLS certificate (public key) string used with HTTPS server. takes precedence over httpsPublicKeyFilepath
  • httpsPrivateKey — TLS private key string used with HTTPS server. takes precedence over httpsPrivateKeyFilepath
  • routes — array of incoming host to origin protocol, host, and port
    • originHost — origin host or IP
    • originPort — origin port
    • originProtocol — origin protocol. one of http: or https:. don't forget the : at the end
    • incomingHostAndPort — incoming host:port to proxy to origin server. picked from HTTP host header field

How to run

  • if installed globally, run fimiproxy ./path/to/config.json
  • if installed locally, run npm exec fimiproxy ./path/to/config.json
  • for one-time run, run npx -y fimiproxy ./path/to/config.json

How to use as lib

import fimiproxy from "fimiproxy"

// start fimiproxy
await fimiproxy.startFimiproxyUsingConfig({
  /** config */ {
    exposeHttpProxy: false,
    exposeHttpsProxy: false,
    httpPort: "80",
    httpsPort: "443",
    routes: [{
      originHost: "localhost",
      originPort: "6001",
      originProtocol: "https:",
      incomingHostAndPort: "www.fimidara.com:80",
    }],
    httpsPublicKey: "",
    httpsPrivateKey: "",
    httpsPublicKeyFilepath: "",
    httpsPrivateKeyFilepath: "",
  },
  /** shouldHandleGracefulShutdown */ true,
  /** exitProcessOnShutdown */ true,
});

// end fimiproxy
await fimiproxy.endFimiproxy(/** exitProcessOnShutdown */ true);

API

  • startFimiproxyUsingConfig — start fimiproxy using config
    • config: FimiproxyRuntimeConfig — see configuration above
    • shouldHandleGracefulShutdown — defaults to true. if true, will listen for SIGINT and SIGTERM, and attempt to gracefully shut down the proxy server
    • exitProcessOnShutdown — defaults to true. if shouldHandleGracefulShutdown is true, will call process.exit() after graceful shutdown. your process may not shut down after SIGINT and SIGTERM if not true. currently untested behaviour (if process will shutdown or not) when set to false and shouldHandleGracefulShutdown is true
  • startFimiproxyUsingConfigFile — start fimiproxy using config read from filepath
    • filepath: string — file at filepath should be a json file, see configuration section above
  • startFimiproxyUsingProcessArgs — start fimiproxy using filepath picked from process.argv[2] see https://nodejs.org/docs/latest/api/process.html#processargv. example, node your-script.js ./path/to/config.json
  • endFimiproxy — gracefully end fimiproxy
    • exitProcess — defaults to true. calls process.exit() if true

Limitations

  • cannot sustain multiple start calls, because current state is managed using a module-global variable. we'll eventually transition to a class-based encapsulation system, so stick around (if you're versed in Typescript, you can contribute to this effort). multiple start calls will either lead to existing servers being garbage collected or memory leak, i haven't tested it. so call endFimiproxy before making another start call. start calls are calls to startFimiproxyUsingConfig, startFimiproxyUsingConfigFile, or startFimiproxyUsingProcessArgs