Skip to content

Commit

Permalink
making it compatible with serverless v3
Browse files Browse the repository at this point in the history
  • Loading branch information
abhijeet-toptal committed Sep 26, 2022
1 parent b04dd48 commit ba49544
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit ba49544

Please sign in to comment.