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.3.1 to 0.3.2

lib/middleware/query.js

2

examples/consul-balancer.js
const rocky = require('..')
const http = require('http')
// See: https://github.com/h2non/rocky-consul

@@ -3,0 +5,0 @@ const consul = require('rocky-consul')

@@ -43,2 +43,5 @@ var http = require('http')

})
.query({
'foo': 'bar'
})

@@ -45,0 +48,0 @@ proxy.listen(3000)

32

lib/base.js

@@ -86,12 +86,14 @@ const MwPool = require('./mwpool')

Base.prototype.useOutgoing =
Base.prototype.useResponse = function () {
this.useFor('response', arguments)
Base.prototype.headers = function (headers) {
this.use(middleware.headers(headers))
return this
}
if (this._interceptResponse) return this
this.use(middleware.responseBody(function (req, res, next) {
this.mw.run('response', req, res, next)
}.bind(this)))
this._interceptResponse = true
Base.prototype.query = function (query) {
this.use(middleware.query(query))
return this
}
Base.prototype.timeout = function (ms) {
this.opts.timeout = ms
return this

@@ -108,10 +110,12 @@ }

Base.prototype.headers = function (headers) {
this.use(middleware.headers(headers))
return this
}
Base.prototype.useOutgoing =
Base.prototype.useResponse = function () {
this.useFor('response', arguments)
Base.prototype.timeout = function (ms) {
this.opts.timeout = ms
if (this.mw.registered('response')) return this
this.use(middleware.responseBody(function (req, res, next) {
this.mw.run('response', req, res, next)
}.bind(this)))
return this
}

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

// Propagate route events to global event bus
// Propagate route events to the global event bus
propagateEvents(rocky, route)
// Propagate middleware to global one
// Propagate middleware to global scope
propagateMiddleware(rocky, route)

@@ -23,0 +23,0 @@

module.exports = {
host: require('./host'),
reply: require('./reply'),
query: require('./query'),
toPath: require('./to-path'),

@@ -5,0 +6,0 @@ headers: require('./headers'),

@@ -34,1 +34,5 @@ const midware = require('midware')

}
MiddlewarePool.prototype.registered = function (name) {
return Array.isArray(this.pool[name])
}

@@ -8,4 +8,2 @@ const common = require('../common')

module.exports = function forward(route, opts, req, res, done) {
done = done || function () {}
// Balance the request, if configured

@@ -12,0 +10,0 @@ var balance = opts.balance

@@ -18,3 +18,2 @@ const http = require('http')

next = next || function () {}
replayStrategy(targets, opts, replayer, next)

@@ -21,0 +20,0 @@ }

const eachSeries = require('./common').eachSeries
const passes = exports.passes = require('./passes')
exports.passes = require('./passes')

@@ -9,7 +9,7 @@ exports.sequentially = function (args, done) {

eachSeries(passes, iterator, done)
eachSeries(exports.passes, iterator, done)
}
exports.concurrently = function (args, done) {
var pending = passes.length
var pending = exports.passes.length

@@ -22,5 +22,5 @@ function finish(err, res) {

passes.forEach(function (pass) {
exports.passes.forEach(function (pass) {
pass.apply(null, args.concat(finish))
})
}
{
"name": "rocky",
"version": "0.3.1",
"description": "Featured, middleware-oriented HTTP/S proxy with traffic replay and intercept",
"version": "0.3.2",
"description": "Full-featured, middleware-oriented HTTP proxy with traffic replay and intercept",
"repository": "h2non/rocky",

@@ -6,0 +6,0 @@ "author": "Tomas Aparicio",

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

rocky is relative young, but production focused project actively maintained and improved.
rocky is relative young, but production focused project actively maintained and constantly improved.
Version `0.1.x` was wrote during my free time in less than 10 days (mostly at night during the weekend), therefore it can be considered in `beta` stage.
Version `0.2.x` introduced significant improvements such as a more consistent API and a new hierarchical middleware layer.
Version `0.2.x` introduced significant improvements, including a consistent API and new hierarchical middleware layer.

@@ -121,9 +121,9 @@ `0.3.x` and higher versions are production-focused. API consistency is guaranteed between patch releases.

- [**0.1.x**](https://github.com/h2non/rocky/tree/v0.1.x) - First version. Initially released at `25.06.2015`. Beta
- [**0.2.x**](https://github.com/h2non/rocky/tree/v0.2.x) - Released at `07.07.2015`.
- [**0.3.x**](https://github.com/h2non/rocky/tree/master) - Production-focused version.
- [**0.2.x**](https://github.com/h2non/rocky/tree/v0.2.x) - Released at `07.07.2015`. Major features and stability improvements.
- [**0.3.x**](https://github.com/h2non/rocky/tree/master) - Released at `24.07.2015`. Production-focused version.
### How does it work?
`rocky` can be useful in [multiple scenarios](#when-rocky-could-be-useful).
A common and representative scenario can be the following:
`rocky` can be useful in [multiple scenarios](#when-rocky-could-be-useful), but a common and representative use case scenario could be the following:
```

@@ -152,4 +152,3 @@ |==============|

One of the more powerful features in `rocky` is its build-in middleware layer.
`rocky` was designed with a main core idea: augment by default.
One of the more powerful features in `rocky` is its build-in domain specific middleware.

@@ -459,3 +458,3 @@ The middleware layer provides a simple and consistent way to augment the proxy functionality very easily, allowing you to attach third-party middleware (also known as plugins) to cover specific tasks which acts between different phases of the proxy, for instance handling incoming/outgoing traffic.

// Overwrite the path
.toPath('/profile/:id')
.toPath('/profile/:id', { id: '0123' })
// Add custom headers

@@ -673,2 +672,16 @@ .headers({

#### route#query([ params | parseFn ])
Parse and expose the query params in `http.IncomingMessage` object via `req.query = Object`.
Additionally you can pass an `object` with additional params to add or a middleware `function(req, res, next)` to work in details with query params.
#### rocky#headers(headers)
Add/extend custom headers to the incoming request before forward/replay it.
#### rocky#timeout(miliseconds)
Define a custom timeout for forward/replay traffic in miliseconds.
#### rocky#router

@@ -719,2 +732,8 @@

#### route#query([ params | parseFn ])
Parse and expose the query params in `http.IncomingMessage` object via `req.query = Object`.
Additionally you can pass an `object` with additional params to add or a middleware `function(req, res, next)` to work in details with query params.
#### route#host(host)

@@ -929,2 +948,6 @@

#### rocky.middleware.query([ query | parserFn ])
Add/extend custom query string params to the incoming request.
#### rocky.middleware.host(host)

@@ -931,0 +954,0 @@

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