Compare commits

...

4 Commits

Author SHA1 Message Date
1ccd53ce69 1.0.5 2019-08-20 19:02:13 +02:00
1264542410 fix(core): update 2019-08-20 19:02:13 +02:00
ba55019846 1.0.4 2019-08-20 18:43:15 +02:00
6f967553d6 fix(core): update 2019-08-20 18:43:15 +02:00
8 changed files with 77 additions and 17 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartproxy", "name": "@pushrocks/smartproxy",
"version": "1.0.3", "version": "1.0.5",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartproxy", "name": "@pushrocks/smartproxy",
"version": "1.0.3", "version": "1.0.5",
"private": false, "private": false,
"description": "a proxy for handling high workloads of proxying", "description": "a proxy for handling high workloads of proxying",
"main": "dist/index.js", "main": "dist/index.js",
@ -25,5 +25,16 @@
"@types/http-proxy-middleware": "^0.19.3", "@types/http-proxy-middleware": "^0.19.3",
"express": "^4.17.1", "express": "^4.17.1",
"http-proxy-middleware": "^0.19.1" "http-proxy-middleware": "^0.19.1"
} },
"files": [
"ts/*",
"ts_web/*",
"dist/*",
"dist_web/*",
"dist_ts_web/*",
"assets/*",
"cli.js",
"npmextra.json",
"readme.md"
]
} }

26
readme.md Normal file
View File

@ -0,0 +1,26 @@
# @pushrocks/smartproxy
a proxy for handling high workloads of proxying
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartproxy)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartproxy)
* [github.com (source mirror)](https://github.com/pushrocks/smartproxy)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartproxy/)
## Status for master
[![build status](https://gitlab.com/pushrocks/smartproxy/badges/master/build.svg)](https://gitlab.com/pushrocks/smartproxy/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartproxy/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartproxy/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartproxy.svg)](https://www.npmjs.com/package/@pushrocks/smartproxy)
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartproxy/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartproxy)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
## Usage
For further information read the linked docs at the top of this readme.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

View File

@ -1,6 +1,6 @@
export interface IHostConfig { export interface IHostConfig {
hostName: string; hostName: string;
destination: string; destinationIp: string;
destinationPort: number; destinationPort: number;
privateKey: string; privateKey: string;
publicKey: string; publicKey: string;

View File

@ -2,4 +2,7 @@ import * as plugins from './smartproxy.plugins';
export class SmartproxyRouter { export class SmartproxyRouter {
public routeReq(req: plugins.express.Request) {
return '';
}
} }

View File

@ -13,7 +13,7 @@ export class SmartProxy {
public addHostCandidate(hostCandidate: interfaces.IHostConfig) { public addHostCandidate(hostCandidate: interfaces.IHostConfig) {
// TODO search for old hostCandidates with that target // TODO search for old hostCandidates with that target
this.hostCandidates.push(hostCandidate); this.hostCandidates.push(hostCandidate);
}; }
/** /**
* starts the proxyInstance * starts the proxyInstance
@ -21,6 +21,31 @@ export class SmartProxy {
public async start() { public async start() {
this.expressInstance = plugins.express(); this.expressInstance = plugins.express();
this.httpsServer = plugins.https.createServer(this.expressInstance); this.httpsServer = plugins.https.createServer(this.expressInstance);
for (const hostCandidate of this.hostCandidates) {
this.httpsServer.addContext(hostCandidate.hostName, {
cert: hostCandidate.publicKey,
key: hostCandidate.privateKey
});
}
// proxy middleware options
const proxyOptions: plugins.httpProxyMiddleware.Config = {
target: 'http://www.example.org', // target host
changeOrigin: true, // needed for virtual hosted sites
ws: true, // proxy websockets
pathRewrite: {
'^/api/old-path': '/api/new-path', // rewrite path
'^/api/remove/path': '/path' // remove base path
},
router: (req: plugins.express.Request) => {
return this.router.routeReq(req);
}
};
this.expressInstance.use(plugins.httpProxyMiddleware(proxyOptions));
} }
public async update() { public async update() {

View File

@ -1,15 +1,10 @@
// node native scope // node native scope
import * as https from 'https'; import * as https from 'https';
export { export { https };
https
};
// third party scope // third party scope
import express from 'express'; import express from 'express';
import * as httpProxyMiddleware from 'http-proxy-middleware'; import httpProxyMiddleware from 'http-proxy-middleware';
export { export { express, httpProxyMiddleware };
express,
httpProxyMiddleware
};