proxy.sh
v1.3.1
Published
Local API Gateway proxy
Readme
proxy.sh
Proxy server that emulates a simple AWS API Gateway locally. The published package already includes the compiled JavaScript so it can be executed directly with npx or after installing globally.
Installation
Use npx to run the latest released version without installing:
npx proxy.sh start --helpOr install globally and use the proxy command:
npm install -g proxy.sh
proxy start --helpUsage
Run with inline configuration:
npx proxy.sh start -p 8000 \
--node auth:http://localhost:9000 \
--node products:http://localhost:9001If you omit options the CLI will prompt for them using inquirer. When stored configurations exist, the CLI also lets you select one to use.
Config files
Save a configuration to ~/.proxy/myconfig.json using --save:
npx proxy.sh start --save myconfigRun the gateway using that configuration:
npx proxy.sh start --config myconfigConfigurations are stored as JSON objects where each property maps a node to its destination:
{
"port": 8000,
"nodes": {
"auth": "http://localhost:9001/auth",
"invoices": "http://localhost:9002/invoices"
},
"log": true,
"cors": {
"origin": ["http://example.com"],
"methods": ["GET"],
"allowedHeaders": ["Content-Type"]
}
}Background mode
Start the gateway in the background and log each service to
~/.proxy/logs/[node].log:
npx proxy.sh start --config myconfig --daemonView a service log:
npx proxy.sh logs authOptions (start command)
-p, --portPort to listen on.-n, --nodeNode mapping innode:destinyform (repeatable).-c, --configConfiguration name or path.-s, --saveSave provided/interactive options as configuration.--logEnable console request logging.--daemonRun in background.--corsEnable CORS.--cors-originAllowed CORS origin (repeatable).--cors-methodAllowed CORS method (repeatable).--cors-headerAllowed CORS header (repeatable). For viewing logs use:
npx proxy.sh logs <node>License
MIT
Development
The compiled JavaScript in dist/ is generated automatically by a GitHub Action when code is pushed to main. The workflow uses conventional commits to determine the next version, installs dependencies with caching, runs the Jest test suite, builds the TypeScript sources with Node 22 and then publishes the release with sources and compiled output. The same workflow also publishes the package to npm using the generated version.
Local builds can be run with:
npm run buildTests are executed with Jest:
npm test