Proxy it. No wait, mock it!
Just delicious when testing and developing.
Relies on
node-http-proxy and
node http api
Description
A simple command line to quickly start a web server which proxys your requests to an external server or to local files (JSON).
Very helpful for testing and development.
Not made to be used in production. Use at your own risk.
Getting Started
Install warp-proxy using npm
:
npm install warp-proxy
npm install warp-proxy --save-dev
Usage
warp-proxy web --port 6543 --target http://mydesiredserver:1234
warp-proxy mock --port 6543 --directory ./mymocksfolder/
warp-proxy run --config ./proxy-config.js
npx warp-proxy web --port 6543 --target http://mydesiredserver:1234
Configuration
When using the run
command you can pass a custom configuration via the --config
argument.
module.exports = {
mode: 'web',
port: 1234,
target: 'http://mydesiredserver:1234',
directory: './folder/with/mocks',
}
Proxying a web target
Relies on all properties from node-http-proxy
Feel free to extend your config file with any property from node-http-proxy
module.exports = {
port: 1234,
target: 'http://mydesiredserver:1234',
...node_http_proxy_properties
}
Proxying local files
Assuming your directory is: --directory ./root/
To mock the following request:
[GET] http:
└───────────────────────┘ └──────────┘ └────────────┘ └──────────────┘
root folder + /GET/ | FOLDER | FOLDER | JSON FILE
your folder structure should look like this
└─root
└─GET
└─repositories
└─administrators
└─1234?param=value.json
Here's a second example:
[PUT] http:
└───────────────────────┘ └──────┘ └───────┘
root folder + /PUT/ | FOLDER |JSON FILE
your folder structure should look like this
└─root
└─PUT
└─language
└─countries.json
License
MIT licensed