Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rocky

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rocky - npm Package Compare versions

Comparing version 0.2.3 to 0.2.4

23

lib/create.js

@@ -1,9 +0,10 @@

const _ = require('lodash')
const rocky = require('..')
const rocky = require('..')
const morgan = require('morgan')
const isPlainObject = require('lodash').isPlainObject
const defaultPort = 3000
const defaultPort = 3000
const reservedKeys = ['forward', 'replay', 'target']
module.exports = function (config) {
if (!config) {
if (!isPlainObject(config)) {
throw new TypeError('config argument is required')

@@ -17,2 +18,6 @@ }

if (!config.mute) {
proxy.use(morgan('combined'))
}
if (config.forward) {

@@ -45,3 +50,3 @@ proxy.forward(config.forward)

})
.filter(_.isPlainObject)
.filter(isPlainObject)
.filter(function (route) {

@@ -60,3 +65,3 @@ return isValidMethod(route.method)

if (route.balance) {
addBalance(proxy, route.balance)
router.balance(route.balance)
}

@@ -78,3 +83,3 @@

})
.filter(_.isPlainObject)
.filter(isPlainObject)
.forEach(function (replay) {

@@ -87,3 +92,5 @@ proxy.replay(replay)

if (typeof urls === 'string') {
urls = urls.split(',')
urls = urls.split(',').map(function (url) {
return url.trim()
})
}

@@ -90,0 +97,0 @@ proxy.balance(urls)

@@ -1,5 +0,4 @@

const _ = require('lodash')
const common = require('./common')
const common = require('./common')
const errors = require('./errors')
const Readable = require('stream').Readable
const errors = require('./errors')

@@ -6,0 +5,0 @@ module.exports = function forward(route, opts, req, res) {

@@ -6,4 +6,4 @@ const Dispatcher = require('./dispatcher')

'proxy:error', 'replay:start',
'replay:error', 'error',
'proxyReq', 'proxyRes'
'replay:error', 'replay:end',
'error', 'proxyReq', 'proxyRes'
]

@@ -10,0 +10,0 @@

@@ -11,2 +11,3 @@ const midware = require('midware')

var pool = this.pool[name]
if (!pool) {

@@ -13,0 +14,0 @@ pool = this.pool[name] = midware()

const http = require('http')
const https = require('https')
const _ = require('lodash')
const parseUrl = require('url').parse
const common = require('./common')
const FakeResponse = require('./response')
const assign = require('lodash').assign
const setupReq = require('http-proxy/lib/http-proxy/common').setupOutgoing

@@ -30,3 +30,3 @@

.map(function (replay) {
return _.assign({}, opts, replay)
return assign({}, opts, replay)
})

@@ -89,8 +89,10 @@ }

request.once('error', function (err) {
request.on('error', function(err) {
route.proxy.emit('replay:error', err, req)
})
request.on('end', function () {
request.on('finish', function () {
route.proxy.emit('replay:end', params, opts, req)
request.removeAllListeners('error')
request.removeAllListeners('finish')
})

@@ -97,0 +99,0 @@

{
"name": "rocky",
"version": "0.2.3",
"version": "0.2.4",
"description": "Pluggable, versatile and middleware-oriented full featured HTTP/S proxy with traffic replay and intercept",

@@ -41,2 +41,3 @@ "repository": "h2non/rocky",

"midware": "^0.1.1",
"morgan": "^1.6.1",
"raw-body": "^2.1.2",

@@ -43,0 +44,0 @@ "router": "^1.1.1",

@@ -73,3 +73,3 @@ # 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)

- As intermediate test server intercepting and generating random/fake responses
- And whatever a programmatic HTTP proxy could be useful to
- And whatever a programmatic HTTP proxy can be useful to

@@ -89,4 +89,4 @@ ## Installation

- [linux-x64](https://github.com/h2non/rocky/releases/download/0.2.3/rocky-0.2.3-linux-x64.nar)
- [darwin-x64](https://github.com/h2non/rocky/releases/download/0.2.3/rocky-0.2.3-darwin-x64.nar)
- [linux-x64](https://github.com/h2non/rocky/releases/download/0.2.4/rocky-0.2.4-linux-x64.nar)
- [darwin-x64](https://github.com/h2non/rocky/releases/download/0.2.4/rocky-0.2.4-darwin-x64.nar)

@@ -295,2 +295,3 @@ Packaged using [nar](https://github.com/h2non/nar). Shipped with node.js `0.12.7`

--balance, -b Define server URLs to balance between, separated by commas
--mute, -m Disable HTTP traffic log in stdout [boolean]
--debug, -d Enable debug mode [boolean]

@@ -789,3 +790,4 @@ -v, --version Show version number [boolean]

- **replay:start** `params, opts, req` - Fired before a replay request starts
- **replay:error** `opts, err, req, res` - Fired when the replay request fails
- **replay:error** `opts, err, req, res` - Fired when a replay request fails
- **replay:end** `params, opts, req` - Fired when a replay request ends
- **server:error** `err, req, res` - Fired on server middleware error. Only available if running as standalone HTTP server

@@ -792,0 +794,0 @@ - **route:missing** `req, res` - Fired on missing route. Only available if running as standalone HTTP server

@@ -11,3 +11,3 @@ const fs = require('fs')

var config = __dirname + '/fixtures/test.toml'
var cmd = __dirname + '/../bin/rocky --port 8098 --config "' + config + '"'
var cmd = __dirname + '/../bin/rocky -m --port 8098 --config "' + config + '"'

@@ -14,0 +14,0 @@ var server = createServer(8099)

@@ -35,2 +35,3 @@ const fs = require('fs')

port: ports.proxy,
mute: true
}

@@ -37,0 +38,0 @@

@@ -0,3 +1,5 @@

const stream = require('stream')
const Socket = require('net').Socket
const Request = require('http').IncomingMessage
const expect = require('chai').expect
const stream = require('stream')
const middleware = require('../../lib/middleware')

@@ -10,3 +12,3 @@

res = new stream.Writable
req = new stream.Readable
req = new Request(new Socket)
req.headers = {}

@@ -30,29 +32,22 @@ req._read = function () {

/*
test('transform', function (done) {
req.on('end', function () {
expect(req.body).to.be.equal('Pong Ping')
done()
})
test('body already present', function (done) {
req.body = new Buffer('Ping Pong')
middleware.requestBody(middlewareFn)
(req, res, function () {})
pushData()
(req, res, done)
})
test('filter', function (done) {
req.on('end', function () {
expect(req.body).to.be.equal('Pong Ping')
done()
})
test('filter function', function (done) {
function filter(req) {
return !req.headers['content-type']
return req.headers['content-type']
}
var mw = middleware.requestBody(middlewareFn, filter)
mw(req, res, function () {})
middleware.requestBody(middlewareFn, filter)
(req, res, done)
})
pushData()
test('filter regexp', function (done) {
req.headers['content-type'] = 'text/html; charset=utf8'
middleware.requestBody(middlewareFn, /application\/json/i)
(req, res, done)
})

@@ -64,22 +59,4 @@

middleware.requestBody(middlewareFn)
(req, res, function (err) {
expect(err).to.be.undefined
done()
})
pushData()
(req, res, done)
})
test('body already present', function (done) {
req.body = 'blablabla'
middleware.requestBody(middlewareFn)
(req, res, function (err) {
expect(err).to.be.null
done()
})
pushData()
})
*/
})

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc