Skip to content

Commit

Permalink
Merge pull request #12 from abhijeet-toptal/chore/serverless-v3
Browse files Browse the repository at this point in the history
compatible with serverless v3
  • Loading branch information
nenadpnc authored Sep 28, 2022
2 parents b04dd48 + 8305dfd commit 93374c8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 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
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit 93374c8

Please sign in to comment.