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

gateway-node

v1.0.1

Published

<b>Proxy Server</b> serves as a hub through which request redirected to many other server which help in hiding resources servers from direct expose.

Downloads

4

Readme

Proxy Server & API Gateway using Core NodeJs 🚀

Proxy Server serves as a hub through which request redirected to many other server which help in hiding resources servers from direct expose.

API Gateway is an API management tool that sits between a client and set of many backend servers. An API Gateway acts as a reverse proxy to accept all (API) request calls, aggregate the various services required to fulfill them, and return the respective response of services.

Contents

How it works 📖

This library work on NodeJs core http module which is used for creating http server and also for making request to other backend servers. In that library, Client request is piped to the backend server which also improve the performance compare to other framework based proxy server. And it alo don't have any extra dependency which also decreases the dependency resolve cost. we can also use cluster NodeJs module above this library for getting the best production-ready performance.

How to use as proxy server 🖊

const { server, registerRoutes} = require('gateway-node');

// create your server object for redirection
let configDetail = {
    server1: {
        hostname:"www.backend1.com",
        port: 8000
    },
    server2: {
        hostname:"127.0.0.1",
        port: 4000
    },
    server3: {
        hostname:"127.0.0.1",
        port: 3000
    }
};

// Function exposed from library for registering set of backend server
/**
 * @name registerRoutes
 * @description Used for registering servers so, proxy server can forward
 * @param {Object} configDetail [key]: [value]
 * [key] is used for identify the request from prefix first param
 * [value] is used for redirecting based on key found in url prefix
*/
registerRoutes(configDetail);

// Proxy http server port and other details same as http createServer module
server.listen(7000);

};
/**
 Like there is a GET Request for resource server as
 BACKEND_URL: 127.0.0.1:4000/getRecords?start=0&limit=20
 METHOD: GET
 */
    REQUEST_URL: 127.0.0.1:7000/server2/getRecords?start=0&limit=20
    METHOD: GET
/**
 * NOTE- Now you have to request as REQUEST_URL,
 * library automatically check
 * "server2" as key and remove it from REQUEST_URL
 * and create it as BACKEND_URL
 * and then library make a http request
 * and also pipe the header and payload from
 * original request.
 */