Run a proxy that routes your different projects using their package.json files
Run a proxy that routes your different projects using their package.json files.
Uses bouncy as proxy engine.
miniproxy explores your apps directory (configurable) and opens each package.json file. If it finds a
routes attribute, it will use it to configure the proxy. Once all the routing info has been gathered, the proxy starts to run.
A basic setup would be:
.|_ proxy.js|_ nodes_modules/| |_ miniproxy|_ apps/|_ app1/|_ package.json|_ ...|_ app2/|_ package.json|_ ...|_ ...
Example of package.json containing a
After reading this package.json file,
miniproxy will route
www.app1.dev hosts to
npm install miniproxy
Use it (proxy.js file example):
// For each folder inside apps/ directory,// extract routing info from package.json file// then start a proxy with these routes on port 80require'miniproxy'use__dirname+'/apps'listen80;
If you want to run your proxy continuously, you can use forever:
forever start proxy.js
Note that your apps are not started by
miniproxy. You have to take care of it (launch them with forever may also be a good idea).