1.2.1 • Published 1 year ago

nx-ngrok v1.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

nx–ngrok — Secure tunnels for your targets.

Contents

Features

  • Use Ngrok to create a secure tunnel to your applications.
  • Manually define the tunnel settings.
  • Alternatively, let Ngrok wrap your existing targets to automatically read the server URL.
  • Generate a new Ngrok tunnel target for your existing apps.

Installing

Using pnpm:

pnpm add -D nx-ngrok
npm install -D nx-ngrok
yarn add -D nx-ngrok

Getting Started

Before you can serve HTML content, Ngrok requires you to sign up for a free ngrok account to get an authtoken.

It is recommended to follow Ngrok's documentation and install your authtoken.

Alternatively, you can set the authtoken via an Environment Variable or as an option in each executor.

Warning

Keep your authtoken private and safe. Do not commit it to git!

Supported Environment Variables

  • NGROK_AUTHTOKEN - Specifies the authentication token (authtoken) used to connect to the ngrok service.

Executors

tunnel

Start a new Ngrok tunnel.

"targets": {
  "dev": {
    "executor": "nx-ngrok:tunnel",
    "options": {
      "target": "examples-nextjs:serve",
    },
  },
}
NameTypeRequiredDefaultDescription
targetstring--Server target to run tunnel for.
protocolhttp, tcp, tls-httpThe tunnel protocol name. This defines the type of tunnel you would like to start.
addressstring, number--Forward traffic to this local port number or network address.
authstring--HTTP Basic authentication for tunnel.
porttargetDefault, auto, number-targetDefaultOverride the target's port number — only supported if the target accepts a port setting.
subdomainstring--Subdomain name to request. If unspecified, ngrok provides a unique subdomain based on your account type.
authTokenstring--Specifies the authentication token (authtoken) used to connect to the ngrok service.
regionus, eu, au, ap, sa, jp, in-usChoose the region where the ngrok agent will connect to host its tunnels.
ngrokConfigstring--Custom path for ngrok config file.

Generators

tunnel

Generate a target to run a Ngrok tunnel for a local server.

nx generate nx-grok:tunnel dev --project=my-app --target=serve
>  NX  Generating nx-ngrok:tunnel

UPDATE apps/my-app/project.json
NameAliasTypeRequiredDefaultDescription
name-string-Target name.
project-string-What project does the target belong to?
target-string--Server target to run tunnel for.
porttargetDefault, auto, number-targetDefaultOverride the target's port number — only supported if the target accepts a port setting.
protocol-http, tcp, tls-httpThe tunnel protocol name. This defines the type of tunnel you would like to start.
address-string, number--Forward traffic to this local port number or network address.
auth-string--HTTP Basic authentication for tunnel.
subdomain-string--Subdomain name to request. If unspecified, ngrok provides a unique subdomain based on your account type.
region-us, eu, au, ap, sa, jp, in-usChoose the region where the ngrok agent will connect to host its tunnels.

Examples

NamePath
nestexamples/nest
nextjsexamples/nextjs
nx-meshexamples/nx-mesh-app

Compatibility

nx-ngrokNx
^1.0.0^15.7.1

Credits

This plugin wouldn't be possible without the great teams behind these projects:

  • Ngrok - A simplified API-first ingress-as-a-service that adds connectivity, security, and observability to your apps in one line
  • Ngrok Node API - A Node wrapper for Ngrok's API.
  • Nrwl - The team behind Nx

Please show them your support! ❤️