node-CocProxy
Convention over Configuration Proxy written in Node.js.
If you access http://localhost:8087/http://example.com/script.js
, then the proxy get following:
- if found
<Current Directory>/example.com/script.js
- access to
<Current Directory>/example.com/script.js
- access to
- if not found
- access to
http://example.com/script.js
- access to
Installation
npm install -g cocproxy
Usage
Command Line
$ cocproxy [options]
Options:
-h, --help Show help.
-v, --version Outputs the version number.
-d, --mock-file-dir path::String Set mock file from this directory
-p, --port Number Set port number to thi proxy
- run
$ cocproxy -p 8098
- set proxy url for browser
- localhost:8098
- Access http://example.com/example.css
- if found
<WORKING_ROOT>/example.com/example.css
, then return this local file. - if couldn't found, then return http://example.com/example.css
- if found
Node API
cocproxy.js
var CocProxy = require("cocproxy").CocProxy;
var options = {
port : 8087,
mockFileDir : "./"
}
var cocProxy = new CocProxy(options);
cocProxy.start();
// proxing
cocProxy.exit();
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
License
MIT