Skip to content

Files

Latest commit

23107e7 · Jan 7, 2025

History

History

ngrok

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Jan 16, 2024
Jan 16, 2024
Sep 4, 2024
Jan 16, 2024
Mar 11, 2024
Jan 16, 2024
Jan 16, 2024
Mar 11, 2024
Jul 1, 2024
Jan 7, 2025
Jan 7, 2025
Apr 3, 2024
Feb 15, 2024

Wing ngrok support

This library can be used to create an ngrok tunnel for local development that forwards HTTP requests to a localhost endpoint.

When compiled to the cloud, this resource is a no-op.

Prerequisites

Installation

npm i @winglibs/ngrok

Usage

Let's forward all requests that are sent to eladb.ngrok.dev to our cloud.Api.

bring ngrok;

let api = new cloud.Api();

api.get("/", inflight () => {
  return {
    status: 200,
    body: "hello ngrok!"
  };
});

let t = new ngrok.Tunnel(api.url, 
  domain: "eladb.ngrok.dev",

  // optional callback
  onConnect: inflight (url: str) => {
    log("connected to {url}");
  },
);

// you can add listeners
t.onConnect(inflight (url) => {
  log("url: {url}");
});

new cloud.Function(inflight () => {
  log("tunnel connected to {t.url}");
});

Once a tunnel is initialized, if an onConnect callback is set, it will be called with the external URL of the tunnel. You can use this hook, for example, to update a webhook URL with a dynamic ngrok endpoint.

Maintainers

License

This library is licensed under the MIT License.