Comparing version 0.1.9 to 0.1.10
@@ -12,8 +12,8 @@ var http = require('http') | ||
.on('proxyReq', function (proxyReq, req, res, opts) { | ||
console.log('New request:', req.url, 'to', opts.target) | ||
console.log('Proxy request:', req.url, 'to', opts.target) | ||
}) | ||
.on('proxyRes', function (proxyRes, req, res) { | ||
console.log('New response:', req.url, 'with status', res.statusCode) | ||
console.log('Proxy response:', req.url, 'with status', res.statusCode) | ||
}) | ||
.on('error', function (err, req, res) { | ||
.on('proxy:error', function (err, req, res) { | ||
console.log('Proxy error:', err) | ||
@@ -35,8 +35,8 @@ }) | ||
.on('proxyReq', function (proxyReq, req, res, opts) { | ||
console.log('New request:', req.url, 'to', opts.target) | ||
console.log('Proxy request:', req.url, 'to', opts.target) | ||
}) | ||
.on('proxyRes', function (proxyRes, req, res) { | ||
console.log('New response:', req.url, 'with status', res.statusCode) | ||
console.log('Proxy response:', req.url, 'with status', res.statusCode) | ||
}) | ||
.on('error', function (err, req, res) { | ||
.on('proxy:error', function (err, req, res) { | ||
console.log('Proxy error:', err) | ||
@@ -43,0 +43,0 @@ }) |
@@ -16,3 +16,3 @@ var http = require('http') | ||
.replay('http://localhost:3002') | ||
.on('error', function (err) { | ||
.on('proxy:error', function (err) { | ||
console.log('Error:', err) | ||
@@ -19,0 +19,0 @@ }) |
@@ -134,3 +134,6 @@ var http = require('http') | ||
function handler(err) { | ||
route.proxy.emit('route:error', err) | ||
route.proxy.emit('proxy:error', err) | ||
if (res.headersSent) { return } | ||
res.writeHead(500, { 'Content-Type': 'application/json' }) | ||
res.end(JSON.stringify({ message: err.message || err })) | ||
} | ||
@@ -137,0 +140,0 @@ } |
{ | ||
"name": "rocky", | ||
"version": "0.1.9", | ||
"version": "0.1.10", | ||
"description": "Pluggable and middleware-oriented full featured HTTP/S proxy router", | ||
@@ -5,0 +5,0 @@ "repository": "h2non/rocky", |
@@ -90,4 +90,4 @@ # rocky [![Build Status](https://api.travis-ci.org/h2non/rocky.svg?branch=master&style=flat)](https://travis-ci.org/h2non/rocky) [![Code Climate](https://codeclimate.com/github/h2non/rocky/badges/gpa.svg)](https://codeclimate.com/github/h2non/rocky) [![NPM](https://img.shields.io/npm/v/rocky.svg)](https://www.npmjs.org/package/rocky) ![Downloads](https://img.shields.io/npm/dm/rocky.svg) | ||
- [linux-x64](https://github.com/h2non/rocky/releases/download/0.1.9/rocky-0.1.9-linux-x64.nar) | ||
- [darwin-x64](https://github.com/h2non/rocky/releases/download/0.1.9/rocky-0.1.9-darwin-x64.nar) | ||
- [linux-x64](https://github.com/h2non/rocky/releases/download/0.1.10/rocky-0.1.10-linux-x64.nar) | ||
- [darwin-x64](https://github.com/h2non/rocky/releases/download/0.1.10/rocky-0.1.10-darwin-x64.nar) | ||
@@ -270,2 +270,11 @@ Packaged using [nar](https://github.com/h2non/nar) | ||
.options({ forwardHost: true }) | ||
.on('proxy:error', function (err) { | ||
console.error('Error:', err) | ||
}) | ||
.on('proxyReq', function (proxyReq, req, res, opts) { | ||
console.log('Proxy request:', req.url, 'to', opts.target) | ||
}) | ||
.on('proxyRes', function (proxyRes, req, res) { | ||
console.log('Proxy response:', req.url, 'with status', res.statusCode) | ||
}) | ||
@@ -528,3 +537,3 @@ // Configure the routes to forward/replay | ||
- **proxyRes** `opts, proxyRes, req, res` - Fired when the target server respond | ||
- **error** `err, req, res` - Fired when the forward request fails | ||
- **proxy:error** `err` - Fired when the proxy request fails | ||
- **route:error** `err, req, res` - Fired when cannot forward/replay the request or middleware error | ||
@@ -531,0 +540,0 @@ - **replay:start** `params, opts, req` - Fired before a replay request starts |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
68572
1526
590