GithubHelp home page GithubHelp logo

serviejs / microservice-proxy Goto Github PK

View Code? Open in Web Editor NEW
8.0 2.0 2.0 795 KB

Simple proxy for your microservices based on servie and path-to-regexp

License: Other

TypeScript 81.61% JavaScript 18.39%
servie proxy microservice

microservice-proxy's Introduction

Microservice Proxy

NPM version NPM downloads Build status Test coverage

Simple proxy for your microservices based on servie and path-to-regexp.

Installation

npm install microservice-proxy --save

Usage

Create the configuration:

{
  "rules": [
    {
      "path": "/login",
      "methods": ["get"],
      "url": "http://localhost:3001"
    },
    {
      "url": "http://localhost:3000"
    }
  ]
}

Start the proxy:

microservice-proxy -c config.json -p 9000

Or programmatically:

import { proxy } from "microservice-proxy";
import { createHandler } from "servie-http";
import { createServer } from "http";

const app = createHandler(
  proxy([
    {
      url: "http://example.com"
    }
  ])
);

createServer(app).listen(3000);

Background

Originally, this module was going to manage processes themselves and dynamically assign port numbers. Unfortunately, it's a little complex to manage the dependencies between the process ports (leaving this for another day). I found micro-proxy which is designed to do the same sort of thing, but it had a couple of issues - path matching and no HTTP/2 requests. I wrote this using ServieJS as an interesting case-study of how decoupling the request and response can lead to interesting mixups such as this (e.g. this could be deployed to AWS Lambda).

TypeScript

This project is written using TypeScript and publishes the definitions directly to NPM.

License

Apache 2.0

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.