Git Product home page Git Product logo

http-proxy's Introduction

http proxy

A simple reverse proxy for routing hypertext files from different ports to http

Warning

This proxy requires any attached web server to reply with Status Code 200, meaning some tools may not function perfectly, i.e. React apps are required to be built before hosting.

Versions

Packages

Installation

  1. Clone this repository
  2. Open the repository in a terminal
  3. Install packages with: npm install
  4. Modify the routes.example.json and dev-routes.example.json files as needed. (more info under usage)
  5. Rename the files to routes.json and dev-routes.json respectively.
  6. Create any necessary files in the development directory
  7. Start the proxy with: npm start
  8. Make your connection

Usage

ESLint

If you want to use ESLint in your development scripts, remove the .eslintignore file.

Adding and Removing Routes and Development Routes

Read Step 4 for basics,
A web route is written as following:

{
  "url": "example.hostname.com", // The hostname to intercept.
  "route": "localhost:3000" // The route to proxy clients to.
}

A dev route is written as following:

{
    "url": "exampleapi.hostname.com", // The hostname to intercept
    "context": "server.example.ts" // The name of the file to send clients to.
}

Adding multiple can be done the same for either routes file, follow the routes example file for a demonstration for both, just remember that the routes file uses "route" while the dev routes file uses "context".

Contributions

Feel free to make a Pull request, my layout is rather simple,
everything related to the code is within the /src directory,

HTTP-PROXY
│   .gitignore
│   license
│   package-lock.json
│   package.json
│   readme.md
│   tsconfig.json
│   
└───src - Contains all of the functional code/files
    │   index.ts - The Main Script, contains all of the functions and methods to get the HTTP Proxy running.
    │   types.ts - The Main Typing file for Typescript, contains the layouts for the route files.
    │
    ├───development - Contains User API files.
    │   │   server.example.ts - (Example) The User API script, referenced in `dev-routes.example.json`.
    │   │
    │   └───example - (Example) Contains User Library files for the API script.
    │           test.ts - An Example Library File.
    │
    └───routes - Contains the routes.
            dev-routes.example.json - An Example of the dev-routes file.
            routes.example.json - An Example of the web routes file.
            dev-routes.json - The File that the script reads to get dev-routes.
            routes.json - The File that the script reads to get web-routes.

http-proxy's People

Contributors

backwardsuser avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.