Skip to content

remove deprecated 'colors','util' modules #1307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/balancer/simple-balancer-with-websockets.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

var http = require('http'),
httpProxy = require('../../lib/http-proxy');
httpProxy = require('../../lib/http-proxy.js');

//
// A simple round-robin load balancing strategy.
Expand Down
4 changes: 2 additions & 2 deletions examples/balancer/simple-balancer.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

var http = require('http'),
httpProxy = require('../../lib/http-proxy');
httpProxy = require('../../lib/http-proxy.js');
//
// A simple round-robin load balancing strategy.
//
Expand Down Expand Up @@ -61,4 +61,4 @@ http.createServer(function (req, res) {
addresses.push(target.target);
}).listen(8021);

// Rinse; repeat; enjoy.
// Rinse; repeat; enjoy.
14 changes: 6 additions & 8 deletions examples/http/basic-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,19 @@

*/

var util = require('util'),
colors = require('colors'),
http = require('http'),
httpProxy = require('../../lib/http-proxy');
var http = require('http'),
httpProxy = require('../../lib/http-proxy.js');

var welcome = [
'# # ##### ##### ##### ##### ##### #### # # # #',
'# # # # # # # # # # # # # # # # ',
'# # # # # node# # # # # # # # # # # ',
'###### # # # # ##### # # # # # # ## # ',
'# # # # ##### ##### ##### # # ## # ',
'# # # # # # # # # # # # # ',
'# # # # # # # # #### # # # '
].join('\n');

util.puts(welcome.rainbow.bold);
console.log(welcome.rainbow.bold);

//
// Basic Http Proxy Server
Expand All @@ -56,5 +54,5 @@ http.createServer(function (req, res) {
res.end();
}).listen(9003);

util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8003'.yellow);
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9003 '.yellow);
console.log('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8003'.yellow);
console.log('http server '.blue + 'started '.green.bold + 'on port '.blue + '9003 '.yellow);
10 changes: 4 additions & 6 deletions examples/http/concurrent-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@

*/

var util = require('util'),
colors = require('colors'),
http = require('http'),
httpProxy = require('../../lib/http-proxy');
var http = require('http'),
httpProxy = require('../../lib/http-proxy.js');

//
// Basic Http Proxy Server
Expand Down Expand Up @@ -64,5 +62,5 @@ http.createServer(function (req, res) {
}
}).listen(9004);

util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8004'.yellow);
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9004 '.yellow);
console.log('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8004'.yellow);
console.log('http server '.blue + 'started '.green.bold + 'on port '.blue + '9004 '.yellow);
7 changes: 2 additions & 5 deletions examples/http/custom-proxy-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@

*/

var util = require('util'),
colors = require('colors'),
http = require('http'),
httpProxy = require('../../lib/http-proxy');
var httpProxy = require('../../lib/http-proxy.js');

//
// Http Proxy Server with bad target
Expand All @@ -52,4 +49,4 @@ proxy.on('error', function (err, req, res) {
});


util.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8005 '.yellow + 'with custom error message'.magenta.underline);
console.log('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8005 '.yellow + 'with custom error message'.magenta.underline);
8 changes: 3 additions & 5 deletions examples/http/error-handling.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@

*/

var util = require('util'),
colors = require('colors'),
http = require('http'),
httpProxy = require('../../lib/http-proxy');
var http = require('http'),
httpProxy = require('../../lib/http-proxy.js');

//
// HTTP Proxy Server
Expand Down Expand Up @@ -60,4 +58,4 @@ function requestHandler(req, res) {
}

http.createServer(requestHandler).listen(8000);
util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8000'.yellow);
console.log('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8000'.yellow);
14 changes: 6 additions & 8 deletions examples/http/forward-and-target-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@

*/

var util = require('util'),
colors = require('colors'),
http = require('http'),
httpProxy = require('../../lib/http-proxy');
var http = require('http'),
httpProxy = require('../../lib/http-proxy.js');

//
// Setup proxy server with forwarding
Expand Down Expand Up @@ -56,12 +54,12 @@ http.createServer(function (req, res) {
// Target Http Forwarding Server
//
http.createServer(function (req, res) {
util.puts('Receiving forward for: ' + req.url);
console.log('Receiving forward for: ' + req.url);
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.write('request successfully forwarded to: ' + req.url + '\n' + JSON.stringify(req.headers, true, 2));
res.end();
}).listen(9007);

util.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8006 '.yellow + 'with forward proxy'.magenta.underline);
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9006 '.yellow);
util.puts('http forward server '.blue + 'started '.green.bold + 'on port '.blue + '9007 '.yellow);
console.log('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8006 '.yellow + 'with forward proxy'.magenta.underline);
console.log('http server '.blue + 'started '.green.bold + 'on port '.blue + '9006 '.yellow);
console.log('http forward server '.blue + 'started '.green.bold + 'on port '.blue + '9007 '.yellow);
12 changes: 5 additions & 7 deletions examples/http/forward-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@

*/

var util = require('util'),
colors = require('colors'),
http = require('http'),
httpProxy = require('../../lib/http-proxy');
var http = require('http'),
httpProxy = require('../../lib/http-proxy.js');

//
// Setup proxy server with forwarding
Expand All @@ -43,11 +41,11 @@ httpProxy.createServer({
// Target Http Forwarding Server
//
http.createServer(function (req, res) {
util.puts('Receiving forward for: ' + req.url);
console.log('Receiving forward for: ' + req.url);
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.write('request successfully forwarded to: ' + req.url + '\n' + JSON.stringify(req.headers, true, 2));
res.end();
}).listen(9019);

util.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8019 '.yellow + 'with forward proxy'.magenta.underline);
util.puts('http forward server '.blue + 'started '.green.bold + 'on port '.blue + '9019 '.yellow);
console.log('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8019 '.yellow + 'with forward proxy'.magenta.underline);
console.log('http forward server '.blue + 'started '.green.bold + 'on port '.blue + '9019 '.yellow);
10 changes: 4 additions & 6 deletions examples/http/latent-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@

*/

var util = require('util'),
colors = require('colors'),
http = require('http'),
httpProxy = require('../../lib/http-proxy');
var http = require('http'),
httpProxy = require('../../lib/http-proxy.js');

//
// Http Proxy Server with Latency
Expand All @@ -50,5 +48,5 @@ http.createServer(function (req, res) {
res.end();
}).listen(9008);

util.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8008 '.yellow + 'with latency'.magenta.underline);
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9008 '.yellow);
console.log('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8008 '.yellow + 'with latency'.magenta.underline);
console.log('http server '.blue + 'started '.green.bold + 'on port '.blue + '9008 '.yellow);
2 changes: 1 addition & 1 deletion examples/http/ntlm-authentication.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var httpProxy = require('http-proxy');
var httpProxy = require('../../lib/http-proxy.js');
var Agent = require('agentkeepalive');

var agent = new Agent({
Expand Down
9 changes: 2 additions & 7 deletions examples/http/proxy-http-to-https.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@
*/

var https = require('https'),
http = require('http'),
util = require('util'),
path = require('path'),
fs = require('fs'),
colors = require('colors'),
httpProxy = require('../../lib/http-proxy');
httpProxy = require('../../lib/http-proxy.js');

//
// Create a HTTP Proxy server with a HTTPS target
Expand All @@ -43,4 +38,4 @@ httpProxy.createProxyServer({
}
}).listen(8011);

util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8011'.yellow);
console.log('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8011'.yellow);
12 changes: 4 additions & 8 deletions examples/http/proxy-https-to-http.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,9 @@

*/

var https = require('https'),
http = require('http'),
util = require('util'),
path = require('path'),
var path = require('path'),
fs = require('fs'),
colors = require('colors'),
httpProxy = require('../../lib/http-proxy'),
httpProxy = require('../../lib/http-proxy.js'),
fixturesDir = path.join(__dirname, '..', '..', 'test', 'fixtures');

//
Expand All @@ -56,5 +52,5 @@ httpProxy.createServer({
}
}).listen(8009);

util.puts('https proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8009'.yellow);
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9009 '.yellow);
console.log('https proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8009'.yellow);
console.log('http server '.blue + 'started '.green.bold + 'on port '.blue + '9009 '.yellow);
9 changes: 3 additions & 6 deletions examples/http/proxy-https-to-https.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,9 @@
*/

var https = require('https'),
http = require('http'),
util = require('util'),
fs = require('fs'),
path = require('path'),
colors = require('colors'),
httpProxy = require('../../lib/http-proxy'),
httpProxy = require('../../lib/http-proxy.js'),
fixturesDir = path.join(__dirname, '..', '..', 'test', 'fixtures'),
httpsOpts = {
key: fs.readFileSync(path.join(fixturesDir, 'agent2-key.pem'), 'utf8'),
Expand All @@ -55,5 +52,5 @@ httpProxy.createServer({
secure: false
}).listen(8010);

util.puts('https proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8010'.yellow);
util.puts('https server '.blue + 'started '.green.bold + 'on port '.blue + '9010 '.yellow);
console.log('https proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8010'.yellow);
console.log('https server '.blue + 'started '.green.bold + 'on port '.blue + '9010 '.yellow);
13 changes: 6 additions & 7 deletions examples/http/reverse-proxy.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/*
reverse-proxy.js: Example of reverse proxying (with HTTPS support)
Copyright (c) 2015 Alberto Pose <albertopose@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
Expand All @@ -23,20 +23,19 @@

var http = require('http'),
net = require('net'),
httpProxy = require('http-proxy'),
url = require('url'),
util = require('util');
httpProxy = require('../../lib/http-proxy.js'),
url = require('url')

var proxy = httpProxy.createServer();

var server = http.createServer(function (req, res) {
util.puts('Receiving reverse proxy request for:' + req.url);
console.log('Receiving reverse proxy request for:' + req.url);

proxy.web(req, res, {target: req.url, secure: false});
}).listen(8213);

server.on('connect', function (req, socket) {
util.puts('Receiving reverse proxy request for:' + req.url);
console.log('Receiving reverse proxy request for:' + req.url);

var serverUrl = url.parse('https://' + req.url);

Expand Down
10 changes: 4 additions & 6 deletions examples/http/sse.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@

*/

var util = require('util'),
colors = require('colors'),
http = require('http'),
httpProxy = require('../../lib/http-proxy'),
var http = require('http'),
httpProxy = require('../../lib/http-proxy.js'),
SSE = require('sse');

//
Expand Down Expand Up @@ -63,5 +61,5 @@ sse.on('connection', function(client) {

server.listen(9003);

util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8003'.yellow);
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9003 '.yellow);
console.log('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8003'.yellow);
console.log('http server '.blue + 'started '.green.bold + 'on port '.blue + '9003 '.yellow);
10 changes: 4 additions & 6 deletions examples/http/standalone-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@

*/

var util = require('util'),
colors = require('colors'),
http = require('http'),
httpProxy = require('../../lib/http-proxy');
var http = require('http'),
httpProxy = require('../../lib/http-proxy.js');

//
// Http Server with proxyRequest Handler and Latency
Expand All @@ -50,5 +48,5 @@ http.createServer(function (req, res) {
res.end();
}).listen(9002);

util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '8002 '.yellow + 'with proxy.web() handler'.cyan.underline + ' and latency'.magenta);
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9002 '.yellow);
console.log('http server '.blue + 'started '.green.bold + 'on port '.blue + '8002 '.yellow + 'with proxy.web() handler'.cyan.underline + ' and latency'.magenta);
console.log('http server '.blue + 'started '.green.bold + 'on port '.blue + '9002 '.yellow);
4 changes: 1 addition & 3 deletions examples/middleware/bodyDecoder-middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@
var http = require('http'),
connect = require('connect'),
request = require('request'),
colors = require('colors'),
util = require('util'),
queryString = require('querystring'),
bodyParser = require('body-parser'),
httpProxy = require('../../lib/http-proxy'),
httpProxy = require('../../lib/http-proxy.js'),
proxy = httpProxy.createProxyServer({});


Expand Down
10 changes: 4 additions & 6 deletions examples/middleware/gzip-middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@

*/

var util = require('util'),
colors = require('colors'),
http = require('http'),
var http = require('http'),
connect = require('connect'),
httpProxy = require('../../lib/http-proxy');
httpProxy = require('../../lib/http-proxy.js');

//
// Basic Connect App
Expand Down Expand Up @@ -61,5 +59,5 @@ http.createServer(function (req, res) {
res.end();
}).listen(9012);

util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8012'.yellow);
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9012 '.yellow);
console.log('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8012'.yellow);
console.log('http server '.blue + 'started '.green.bold + 'on port '.blue + '9012 '.yellow);
Loading