forked from neosavvyinc/neosavvy-javascript-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweb-server.js
More file actions
25 lines (20 loc) · 720 Bytes
/
web-server.js
File metadata and controls
25 lines (20 loc) · 720 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
(function () {
"use strict";
var express = require('express');
var httpProxy = require("http-proxy");
var path = require("path");
var args = process.argv.splice(2);
var basePort = Number(args[0]);
var packageDir = args[1];
function createServer(domain, port) {
var options = {
changeOrigin: true
};
httpProxy.createServer(80, domain, options, proxyRequest).listen(port);
console.log("Port " + port + " is proxying to " + domain);
}
var app = express();
app.use(express.static(packageDir));
app.listen(basePort);
console.log('Package (' + path.resolve(packageDir) + ') is served on http://localhost:' + basePort);
})();