khrj / ngrok

Expose your localhost to the web. Ultra-simple deno wrapper for ngrok.

Home Page:https://deno.land/x/ngrok

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

trains between usb and usb port abstract illustration

ngrok

Expose your localhost to the web. Ultra-simple deno wrapper for ngrok

build status language code size issues license version

View on deno.land




Usage

import { Ngrok } from "https://deno.land/x/ngrok@4.0.2/mod.ts"

const ngrok = await Ngrok.create({
    protocol: "http",
    port: 8080,
})

ngrok.addEventListener("ready", (event) => {
    console.log(event.detail) // Outputs a URL without the protocol, such as "33a229cb0344.ngrok.io"
})

// ...

await ngrok.destroy()
  • Ngrok.create accepts NgrokOptions
interface NgrokOptions {
    protocol: string
    port: number
    region?: string
    subdomain?: string
    authtoken?: string
    extraArgs?: string[]
}

Disconnecting

Due to the way child-processes work, ngrok will continue running in the background even after your program exits unless you destroy the instance

import { Ngrok } from "https://deno.land/x/ngrok@4.0.2/mod.ts"

const ngrok = await Ngrok.create({
    protocol: "http",
    port: 8080,
})

await ngrok.destroy()
  • Optionally provide an exit code: await ngrok.destroy("SIGKILL")

API

See generated documentation

Permissions

  • --allow-read
  • --allow-write
  • --allow-env
  • --allow-net
  • --allow-run
deno run --allow-read --allow-write --allow-env --allow-net --allow-run test.ts

alternatively, specify only -A

deno run -A test.ts

Supporters

Stargazers repo roster for @khrj/ngrok

Forkers repo roster for @khrj/ngrok

Related

About

Expose your localhost to the web. Ultra-simple deno wrapper for ngrok.

https://deno.land/x/ngrok

License:MIT License


Languages

Language:TypeScript 95.2%Language:Nix 4.8%