diff --git a/README.md b/README.md index c2540f3..cde2868 100644 --- a/README.md +++ b/README.md @@ -3,15 +3,15 @@ [![npm](https://img.shields.io/npm/v/serverless-ngrok-tunnel.svg)](https://www.npmjs.com/package/serverless-ngrok-tunnel) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](#contributing) -Serverless plugin that creates ngrok public tunnel on localhost. +Serverless plugin that creates ngrok public tunnel on localhost. Optionally, writes tunnels url to .env file and deletes them after session is over. Useful for when you want to expose url for other applications to use (for example mobile application). ## Installation -Add serverless-ngrok-tunnel to your project: -`npm install --save-dev serverless-ngrok-tunnel` +Add serverless-ngrok-tunnel to your project: +`npm install --save-dev serverless-ngrok-tunnel` -Then inside your `serverless.yml` file add following entry to the plugins section: +Then inside your `serverless.yml` file add following entry to the plugins section: ```yaml plugins: - serverless-ngrok-tunnel @@ -35,18 +35,20 @@ custom: envProp: 'IOT_ENDPOINT' ws: true # expose web-socket url path: '/mqqt' # additional path to url - + - port: 9000 ngrokOptions: # optional. custom ngrok options authtoken: '12345' region: 'us' subdomain: 'my-subdomain' - + ``` -For a list of available ngrok options checkout ngrok [documentation](https://github.com/bubenshchykov/ngrok#options). +For a list of available ngrok options checkout ngrok [documentation](https://github.com/bubenshchykov/ngrok#options). -To start tunnel/s run `sls tunnel`. -If you are using `serverless-offline` plugin, start offline with option flag: `sls offline start --tunnel=true`. +To start tunnel/s run `sls tunnel`. +If you are using `serverless-offline` plugin + - v2: start offline with option flag: `sls offline start --tunnel=true`. + - v3: start offline with option flag: `sls offline start --param="tunnel=true"`. ## Contributing diff --git a/index.js b/index.js index d5efffa..3f84ed1 100644 --- a/index.js +++ b/index.js @@ -76,7 +76,7 @@ class ServerlessTunnel { this.noEnvFile = true } } - if (this.slsOptions.tunnel === 'true' || selfInit) { + if (this.slsOptions.tunnel === 'true' || this.slsOptions.param?.includes('tunnel=true') || selfInit) { if (this.options.tunnels && this.options.tunnels.length) { this.log('Starting tunnels...') this.options.tunnels.forEach((opt) => this.runTunnel(opt)) diff --git a/package-lock.json b/package-lock.json index a0573f4..d554731 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "serverless-ngrok-tunnel", - "version": "0.1.0", + "version": "0.2.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 7c5388c..87d2bbc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "serverless-ngrok-tunnel", - "version": "0.1.0", + "version": "0.2.0", "description": "Serverless plugin that creates ngrok public tunnel on localhost.", "main": "index.js", "repository": {