Skip to content

Commit ce43f73

Browse files
committedOct 25, 2013
Added support for proxy
1 parent 9ddd83e commit ce43f73

File tree

5 files changed

+45
-9
lines changed

5 files changed

+45
-9
lines changed
 

‎Gruntfile.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
var sqlite3 = require('sqlite3').verbose();
1+
// Remove the quotes below and fill in <proxy-ip> and <proxy-port> if you use a proxy
2+
//require('./http-proxy')('<proxy-ip>',<proxy-port>);
23

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

‎README.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Getting started
1414
Install SQLite3
1515

1616
sudo apt-get update
17-
sudo apt-get install sqlite3 git-core -y
17+
sudo apt-get install sqlite3 git-core curl -y
1818

1919
Install node dependencies
2020

@@ -27,6 +27,11 @@ Install bower dependencies
2727

2828
### Setup database and server
2929

30+
If you have a proxy you need to add it to these to files on line 2:
31+
32+
nano +2 Gruntfile.js
33+
nano +2 templates/.bowerrc
34+
3035
Run tests and sync with official Bower repository
3136

3237
grunt
@@ -35,9 +40,6 @@ Configure server location
3540

3641
grunt config:<ip-address>:port
3742

38-
If you have a proxy
39-
40-
gedit templates/.bowerrc
4143

4244
Configure SSH on your server
4345

‎bowers-nest.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
var server = require('./server/server');
22

3-
var port = <port>;
3+
var port = '<port>';
44

5-
server.start(port);
5+
server.start(parseInt(port,10));

‎http-proxy.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
var http = require('http');
2+
var __request = http.request;
3+
exports.request = __request;
4+
5+
var proxy = {
6+
host: '',
7+
port: 0
8+
};
9+
10+
var _debug = false;
11+
12+
http.request = function (options, callback) {
13+
var __options = options;
14+
__options.path = 'http://' + options.host + options.path;
15+
__options.host = proxy.host;
16+
__options.port = proxy.port;
17+
if (_debug) {
18+
console.log('=== http-proxy.js begin debug ===');
19+
console.log(JSON.stringify(__options, null, 2));
20+
console.log('=== http-proxy.js end debug ===');
21+
}
22+
var req = __request(__options, function (res) {
23+
callback(res);
24+
});
25+
return req;
26+
};
27+
28+
module.exports = function (host, port, debug) {
29+
proxy.host = host;
30+
proxy.port = port;
31+
_debug = debug || false;
32+
};

‎templates/.bowerrc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2+
"proxy": "",
23
"directory": "bower_components",
34
"registry": "http://<ip-address>:<port>",
45
"registry.search": "http://<ip-address>:<port>",
56
"registry.register": "http://<ip-address>:<port>",
6-
"registry.publish": "http://<ip-address>:<port>",
7-
"proxy": ""
7+
"registry.publish": "http://<ip-address>:<port>"
88
}

0 commit comments

Comments
 (0)