Skip to content

Commit

Permalink
Added support for proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
presidenten committed Oct 25, 2013
1 parent 9ddd83e commit ce43f73
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 9 deletions.
4 changes: 3 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
var sqlite3 = require('sqlite3').verbose();
// Remove the quotes below and fill in <proxy-ip> and <proxy-port> if you use a proxy
//require('./http-proxy')('<proxy-ip>',<proxy-port>);

var sqlite3 = require('sqlite3').verbose();
var dbName = 'nest.db';
var serverLocation = 'ssh://<ip-address>';

Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Getting started
Install SQLite3

sudo apt-get update
sudo apt-get install sqlite3 git-core -y
sudo apt-get install sqlite3 git-core curl -y

Install node dependencies

Expand All @@ -27,6 +27,11 @@ Install bower dependencies

### Setup database and server

If you have a proxy you need to add it to these to files on line 2:

nano +2 Gruntfile.js
nano +2 templates/.bowerrc

Run tests and sync with official Bower repository

grunt
Expand All @@ -35,9 +40,6 @@ Configure server location

grunt config:<ip-address>:port

If you have a proxy

gedit templates/.bowerrc

Configure SSH on your server

Expand Down
4 changes: 2 additions & 2 deletions bowers-nest.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var server = require('./server/server');

var port = <port>;
var port = '<port>';

server.start(port);
server.start(parseInt(port,10));
32 changes: 32 additions & 0 deletions http-proxy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
var http = require('http');
var __request = http.request;
exports.request = __request;

var proxy = {
host: '',
port: 0
};

var _debug = false;

http.request = function (options, callback) {
var __options = options;
__options.path = 'http://' + options.host + options.path;
__options.host = proxy.host;
__options.port = proxy.port;
if (_debug) {
console.log('=== http-proxy.js begin debug ===');
console.log(JSON.stringify(__options, null, 2));
console.log('=== http-proxy.js end debug ===');
}
var req = __request(__options, function (res) {
callback(res);
});
return req;
};

module.exports = function (host, port, debug) {
proxy.host = host;
proxy.port = port;
_debug = debug || false;
};
4 changes: 2 additions & 2 deletions templates/.bowerrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"proxy": "",
"directory": "bower_components",
"registry": "http://<ip-address>:<port>",
"registry.search": "http://<ip-address>:<port>",
"registry.register": "http://<ip-address>:<port>",
"registry.publish": "http://<ip-address>:<port>",
"proxy": ""
"registry.publish": "http://<ip-address>:<port>"
}

0 comments on commit ce43f73

Please sign in to comment.