Simple proxy that is intended to support on chaos testing.

Overview

Proxy with Behavior

Proxy with Behavior is a node application that work as a reverse proxy, and enables apply some behaviors to be executed in requests.

How to use the API?

The proxy API to handle with behaviors, usually uses port 3001.

How to get it running

To run the proxy using docker, execute the following commands:

docker build -t proxy-with-behavior .

docker run --rm -d -p 3000:3000 -p 3001:3001 -e "NODE_ENV=production" -e "SERVICE_URL=https://jsonplaceholder.typicode.com" --name proxy-with-behavior-container proxy-with-behavior

If you want to apply this proxy, in front of your app, you just need to configure the network (or service) as a proxy. Consider that SERVICE_URL is a environment variable used to determine who is the proxied service.

GET /behaviors

List all stored behaviors

# curl http://localhost:3001/behaviors
{
	"behaviors": [
		{
			"id": 1,
			"type": "change-response",
			"resource": "/posts",
			"method": "POST",
			"status": 500,
			"active": true,
			"data": null,
			"pattern_source":null,
			"pattern_flag":null,
			"createdAt": "2022-01-07T19:58:24.895Z",
			"updatedAt": "2022-01-07T19:58:24.895Z"
		},
		{
			"id": 2,
			"type": "change-response",
			"resource": "/posts",
			"method": "GET",
			"status": 500,
			"active": true,
			"data": null,
			"pattern_source":null,
			"pattern_flag":null,
			"createdAt": "2022-01-07T19:58:29.465Z",
			"updatedAt": "2022-01-07T19:58:29.465Z"
		}
	]
}

POST /behaviors

Store behaviors and return the updated list. It's important to say that you can only associate a single behavior to a resource/method. This means, for instance, if you store a change-response behavior to the method/resource GET /posts, you can't store another behavior to the same method/resource, but if you want it, you can do this to another method of a resource (e.g. latency behavior applied to POST /posts).

# curl -X POST http://localhost:3001/behaviors -d '{"type": "change-response","resource": "/posts","method": "GET","status": 500, "pattern": {"source": "see (chapter \\d+(\\.\\d)*)","flag": "i"} }'
{
	"behaviors": [
		{
			"id": 2,
			"type": "change-response",
			"resource": "/posts",
			"method": "POST",
			"status": 500,
			"active": true,
			"data": null,
			"pattern_source": "see (chapter \\d+(\\.\\d)*)",
			"pattern_flag": "i",
			"createdAt": "2022-01-11T01:33:37.187Z",
			"updatedAt": "2022-01-11T01:33:37.187Z"
		}
	]
}
  • Required fields: type, resource, and method
  • Not required fields: status, pattern.source, pattern.flag, active and data;

When you try latency behavior, use data field and consider this field as timeout in milliseconds value. This means if you use 'data': '5000', the behavior will apply a latency of 5 seconds before execute the request. pattern.source and pattern.flag are used to define a regular expression that will verify where apply the behavior.

PUT /behaviors/:id/toggle

Toggle behavior's active state.

# curl -X PUT http://localhost:3001/behaviors/1/toggle
{
	"behaviors": [
		{
			"id": 2,
			"type": "change-response",
			"resource": "/posts",
			"method": "POST",
			"status": 500,
			"active": true,
			"data": null,
			"pattern_source": "see (chapter \\d+(\\.\\d)*)",
			"pattern_flag": "i",
			"createdAt": "2022-01-11T01:33:37.187Z",
			"updatedAt": "2022-01-11T01:33:37.187Z"
		}
	]
}

DELETE /behaviors/:id

Deletes a behavior by his ID and returns the updated list.

# curl -X DELETE http://localhost:3001/behaviors/1
{
	"behaviors": []
}

Behavior types

  • change-response: Change the response (enables you to change status, or the data returned);
  • latency: Add latency to the request;

What it does?

  • Proxy requests to a service;
  • API to enable behavior's manipulation;
  • Register of change-response behavior, enabling intercept and change status code's response;
  • Register of latency behavior, enabling add latency in milliseconds;
  • It's possible define a regular expression pattern, that will check if a behavior must be applied or not. If none pattern is defined, the behavior will be applied;
  • Toggle of active behavior's state;

What's next

  • On change-response use data attribute as response when exists;
You might also like...

Wrap native HTTP requests with RFC compliant cache support

cacheable-request Wrap native HTTP requests with RFC compliant cache support RFC 7234 compliant HTTP caching for native Node.js HTTP/HTTPS requests. C

Dec 20, 2022

:dash: Simple yet powerful file-based mock server with recording abilities

:dash: Simple yet powerful file-based mock server with recording abilities

💨 smoke Simple yet powerful file-based mock server with recording abilities Just drop a bunch of (JSON) files in a folder and you're ready to go! Bas

Dec 13, 2022

A simple NodeJS WebSocket WebApp vulnerable to blind SQL injection

A simple NodeJS WebSocket WebApp vulnerable to blind SQL injection

NodeJS WebSocket SQLi vulnerable WebApp A one-day build of a vulnerable WebSocket app on NodeJS to practice boolean based SQLi over WebSocket. I made

Dec 27, 2022

一个基于node.js,express,socket.io的websocket非常棒的聊天室,代码简单很适合新手. A very nice websocket chat room based on node.js, express, socket.io. the code is simple, very suitable for novices

一个基于node.js,express,socket.io的websocket非常棒的聊天室,代码简单很适合新手.  A very nice websocket chat room based on node.js, express, socket.io. the code is simple, very suitable for novices

来来往下看,虽然教程又臭又长但是一步步地保姆式教学很简单的,毕竟我是真菜鸟嘛,当然什么都往细了说╮(╯_╰)╭ 一、使用方法 该教程内容所有指令都为Linux CentOS 7.x环境下指令,其他平台请您自行查询(⊙x⊙;) 1.下载node.js并下载Sakura_Chat_Room node.j

Jul 21, 2022

A simple emitter npm package

Emitter A simple emitter package This package is pretty self explanatory... need to get and send events? use an emitter Table of content How to use? P

Feb 26, 2022

The official proxy of Titanium Network with enhanced support for a large majority of sites with hCAPTCHA support. Successor to Alloy Proxy.

Corrosion Titanium Networks main web proxy. Successor to Alloy Installation: npm i corrosion Example: const Corrosion = require('corrosion'); const p

Dec 21, 2022

A testing focused Remix Stack, that integrates E2E & Unit testing with Playwright, Vitest, MSW and Testing Library. Driven by Prisma ORM. Deploys to Fly.io

A testing focused Remix Stack, that integrates E2E & Unit testing with Playwright, Vitest, MSW and Testing Library. Driven by Prisma ORM. Deploys to Fly.io

Live Demo · Twitter A testing focused Remix Stack, that integrates E2E & Unit testing with Playwright, Vitest, MSW and Testing Library. Driven by Pris

Oct 31, 2022

proxy 🦄 yxorp is your Web Proxy as a Service (SAAS) Multi-tenant, Multi-Threaded, with Cache & Article Spinner

proxy 🦄 yxorp is your Web Proxy as a Service (SAAS) Multi-tenant, Multi-Threaded, with Cache & Article Spinner

proxy 🦄 yxorp is your Web Proxy as a Service (SAAS) Multi-tenant, Multi-Threaded, with Cache & Article Spinner. Batteries are included, Content Spinning and Caching Engine, all housed within a stunning web GUI. A unique high-performance, plug-and-play, multi-threaded website mirror and article spinner

Dec 30, 2022

Proxy but misspelled -- closed proxy for the internet

pyrox Proxy that runs on Cloudflare Workers. Setup Install wrangler2. npm install wrangler. Generate a public Ed25519 key, exported under SPKI mode wi

Sep 9, 2022

A simple browser extension, intended to get you "Back To Work" when you start slacking off to one of those really addictive sites.

Back to Work A simple browser extension, intended to get you Back To Work when you start slacking off to one of those really addictive sites. What doe

Nov 19, 2022

🐐 Simple and complete React DOM testing utilities that encourage good testing practices.

🐐 Simple and complete React DOM testing utilities that encourage good testing practices.

React Testing Library Simple and complete React DOM testing utilities that encourage good testing practices. Read The Docs | Edit the docs Table of Co

Jan 4, 2023

🐐 Simple and complete React DOM testing utilities that encourage good testing practices.

🐐 Simple and complete React DOM testing utilities that encourage good testing practices.

React Testing Library Simple and complete React DOM testing utilities that encourage good testing practices. Read The Docs | Edit the docs Table of Co

Jan 4, 2023

Query for CSS brower support data, combined from caniuse and MDN, including version support started and global support percentages.

css-browser-support Query for CSS browser support data, combined from caniuse and MDN, including version support started and global support percentage

Nov 2, 2022

This is a JS/TS library for accelerated tensor computation intended to be run in the browser.

TensorJS TensorJS How to use Tensors Tensor operations Reading values Data types Converting between backends Onnx model support Optimizations Running

Jun 26, 2022

Massive Open-Source Anti-agression Intelligence Collection is intended for civilians to be able to submit and verify intelligence items about an attacking force.

Massive Open-Source Anti-agression Intelligence Collection is intended for civilians to be able to submit and verify intelligence items about an attacking force.

Mar 1, 2022

Updog is an open-source social media webapp intended to allow everyday people to share their thoughts in a welcoming community.

SE701-Updog Updog is an open-source social media webapp intended to allow everyday people to share their thoughts in a welcoming community. This proje

Apr 18, 2022

A minimal & self-hostable alternative to pastebin intended for code

minBin A minimal & self-hostable alternative to pastebin intended for code Use ⌨️ A public instance is available at https://bin.kio.dev/ Building 🔨 n

Dec 29, 2022

An action intended to run on pull request and post a comment summarizing any changes to DevCycle variables.

An action intended to run on pull request and post a comment summarizing any changes to DevCycle variables.

Overview With this Github action, information on which DevCycle features have been added or removed in a code change will be shown directly on each Pu

Jun 14, 2022

A tiny script and component intended to be used with Astro for generating images with eleventy-img.

Astro + eleventy-img A tiny script and component intended to be used with Astro for generating images with eleventy-img. It also supports creating blu

Dec 16, 2022
Owner
José Carlos de Moraes Filho
Javascript Enthusiast
José Carlos de Moraes Filho
Simple, configurable part mock part proxy

Moxy Simple, configurable mock / proxy server. Table of Contents Quick start Programatic CLI Docker Docker compose Usage Programatic Via HTTP requests

Acrontum GmbH 7 Aug 12, 2022
A full-featured http proxy for node.js

node-http-proxy node-http-proxy is an HTTP programmable proxying library that supports websockets. It is suitable for implementing components such as

http ... PARTY! 13.1k Jan 3, 2023
Full-featured, middleware-oriented, programmatic HTTP and WebSocket proxy for node.js

rocky A multipurpose, full-featured, middleware-oriented and hackable HTTP/S and WebSocket proxy with powerful built-in features such as versatile rou

Tom 370 Nov 24, 2022
Global HTTP/HTTPS proxy agent configurable using environment variables.

global-agent Global HTTP/HTTPS proxy configurable using environment variables. Usage Setup proxy using global-agent/bootstrap Setup proxy using bootst

Gajus Kuizinas 267 Dec 20, 2022
A proxy web app that serves ABC iView content outside of the iView webplayer, avoiding intrusive data harvesting.

iview-proxy A proxy web app that serves ABC iView content outside of the iView webplayer, avoiding intrusive data harvesting. There's also a cool Andr

The OpenGov Australia Project 11 Jul 16, 2022
DSC-AlarmServer - Creates web interface to DSC/Envisalink with proxy.

DSC-AlarmServer Creates web interface to DSC/Envisalink with proxy. Since the Envisalink module can only have one connection, this phython script can

null 4 Oct 11, 2022
Prefect API Authentication/Authorization Proxy for on-premises deployments

Proxy Authorization Service for Prefect UI and Prefect CLI Prefect is a great platform for building data flows/pipelines. It supports hybrid execution

Softrams 20 Dec 10, 2022
wabac.js CORS Proxy

wabac.js CORS Proxy This provides a simple CORS proxy, which is designed to run as a Cloudflare Worker. This system is compatible with wabac.js-based

Webrecorder 3 Mar 8, 2022
Highly sophisticated proxy used for evading internet censorship or accessing websites in a controlled sandbox using the power of service-workers and more! Easy deployment version (Node.js)

Ultraviolet-Node The deployable version of Ultraviolet, a highly sophisticated proxy used for evading internet censorship or accessing websites in a c

Titanium Network 27 Jan 2, 2023
Highly sophisticated proxy used for evading internet censorship or accessing websites in a controlled sandbox using the power of service-workers and more! Easy deployment version (Node.js)

Ultraviolet-Node The deployable version of Ultraviolet, a highly sophisticated proxy used for evading internet censorship or accessing websites in a c

Titanium Network 34 Apr 15, 2022