Skip to content
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

Replace deprecated util.puts() and util.debug() with console commands #1575

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 4 additions & 5 deletions examples/http/basic-proxy.js
Expand Up @@ -24,8 +24,7 @@

*/

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

Expand All @@ -38,7 +37,7 @@ var welcome = [
'# # # # # # # # #### # # # '
].join('\n');

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

//
// Basic Http Proxy Server
Expand All @@ -56,5 +55,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);
7 changes: 3 additions & 4 deletions examples/http/concurrent-proxy.js
Expand Up @@ -24,8 +24,7 @@

*/

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

Expand Down Expand Up @@ -64,5 +63,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);
5 changes: 2 additions & 3 deletions examples/http/custom-proxy-error.js
Expand Up @@ -24,8 +24,7 @@

*/

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

Expand All @@ -52,4 +51,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);
5 changes: 2 additions & 3 deletions examples/http/error-handling.js
Expand Up @@ -24,8 +24,7 @@

*/

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

Expand Down Expand Up @@ -60,4 +59,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);
11 changes: 5 additions & 6 deletions examples/http/forward-and-target-proxy.js
Expand Up @@ -24,8 +24,7 @@

*/

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

Expand Down Expand Up @@ -56,12 +55,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);
9 changes: 4 additions & 5 deletions examples/http/forward-proxy.js
Expand Up @@ -24,8 +24,7 @@

*/

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

Expand All @@ -43,11 +42,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);
7 changes: 3 additions & 4 deletions examples/http/latent-proxy.js
Expand Up @@ -24,8 +24,7 @@

*/

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

Expand All @@ -50,5 +49,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);
3 changes: 1 addition & 2 deletions examples/http/proxy-http-to-https.js
Expand Up @@ -26,7 +26,6 @@

var https = require('https'),
http = require('http'),
util = require('util'),
path = require('path'),
fs = require('fs'),
colors = require('colors'),
Expand All @@ -43,4 +42,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);
5 changes: 2 additions & 3 deletions examples/http/proxy-https-to-http.js
Expand Up @@ -26,7 +26,6 @@

var https = require('https'),
http = require('http'),
util = require('util'),
path = require('path'),
fs = require('fs'),
colors = require('colors'),
Expand Down Expand Up @@ -56,5 +55,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);
5 changes: 2 additions & 3 deletions examples/http/proxy-https-to-https.js
Expand Up @@ -26,7 +26,6 @@

var https = require('https'),
http = require('http'),
util = require('util'),
fs = require('fs'),
path = require('path'),
colors = require('colors'),
Expand Down Expand Up @@ -55,5 +54,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);
7 changes: 3 additions & 4 deletions examples/http/reverse-proxy.js
Expand Up @@ -24,20 +24,19 @@
var http = require('http'),
net = require('net'),
httpProxy = require('../../lib/http-proxy'),
url = require('url'),
util = require('util');
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);
var parsedUrl = url.parse(req.url);
var target = parsedUrl.protocol + '//' + parsedUrl.hostname;
proxy.web(req, res, {target: target, 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
7 changes: 3 additions & 4 deletions examples/http/sse.js
Expand Up @@ -24,8 +24,7 @@

*/

var util = require('util'),
colors = require('colors'),
var colors = require('colors'),
http = require('http'),
httpProxy = require('../../lib/http-proxy'),
SSE = require('sse');
Expand Down Expand Up @@ -63,5 +62,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);
7 changes: 3 additions & 4 deletions examples/http/standalone-proxy.js
Expand Up @@ -24,8 +24,7 @@

*/

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

Expand All @@ -50,5 +49,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);
1 change: 0 additions & 1 deletion examples/middleware/bodyDecoder-middleware.js
Expand Up @@ -28,7 +28,6 @@ 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'),
Expand Down
7 changes: 3 additions & 4 deletions examples/middleware/gzip-middleware.js
Expand Up @@ -24,8 +24,7 @@

*/

var util = require('util'),
colors = require('colors'),
var colors = require('colors'),
http = require('http'),
connect = require('connect'),
httpProxy = require('../../lib/http-proxy');
Expand Down Expand Up @@ -61,5 +60,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);
7 changes: 3 additions & 4 deletions examples/middleware/modifyResponse-middleware.js
Expand Up @@ -24,8 +24,7 @@

*/

var util = require('util'),
colors = require('colors'),
var colors = require('colors'),
http = require('http'),
connect = require('connect'),
app = connect(),
Expand Down Expand Up @@ -64,6 +63,6 @@ http.createServer(function (req, res) {
res.end('Hello, I love Ruby\n');
}).listen(9013);

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

9 changes: 4 additions & 5 deletions examples/websocket/latent-websocket-proxy.js
Expand Up @@ -24,8 +24,7 @@

*/

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

Expand All @@ -45,10 +44,10 @@ catch (ex) {
//
var server = io.listen(9016);
server.sockets.on('connection', function (client) {
util.debug('Got websocket connection');
console.error('Got websocket connection');

client.on('message', function (msg) {
util.debug('Got message from client: ' + msg);
console.error('Got message from client: ' + msg);
});

client.send('from server');
Expand Down Expand Up @@ -86,6 +85,6 @@ proxyServer.listen(8016);
var ws = client.connect('ws://localhost:8016');

ws.on('message', function (msg) {
util.debug('Got message: ' + msg);
console.error('Got message: ' + msg);
ws.send('I am the client');
});
9 changes: 4 additions & 5 deletions examples/websocket/standalone-websocket-proxy.js
Expand Up @@ -24,8 +24,7 @@

*/

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

Expand All @@ -45,10 +44,10 @@ catch (ex) {
//
var server = io.listen(9015);
server.sockets.on('connection', function (client) {
util.debug('Got websocket connection');
console.error('Got websocket connection');

client.on('message', function (msg) {
util.debug('Got message from client: ' + msg);
console.error('Got message from client: ' + msg);
});

client.send('from server');
Expand Down Expand Up @@ -83,6 +82,6 @@ proxyServer.listen(8015);
var ws = client.connect('ws://localhost:8015');

ws.on('message', function (msg) {
util.debug('Got message: ' + msg);
console.error('Got message: ' + msg);
ws.send('I am the client');
});
9 changes: 4 additions & 5 deletions examples/websocket/websocket-proxy.js
Expand Up @@ -24,8 +24,7 @@

*/

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

Expand All @@ -45,10 +44,10 @@ catch (ex) {
//
var server = io.listen(9014);
server.sockets.on('connection', function (client) {
util.debug('Got websocket connection');
console.error('Got websocket connection');

client.on('message', function (msg) {
util.debug('Got message from client: ' + msg);
console.error('Got message from client: ' + msg);
});

client.send('from server');
Expand All @@ -65,6 +64,6 @@ httpProxy.createServer({ target: 'ws://localhost:9014', ws: true }).listen(8014)
var ws = client.connect('ws://localhost:8014');

ws.on('message', function (msg) {
util.debug('Got message: ' + msg);
console.error('Got message: ' + msg);
ws.send('I am the client');
});