0.0.12 • Published 8 months ago

@winglibs/ngrok v0.0.12

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

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.

0.0.12

8 months ago

0.0.10

12 months ago

0.0.11

12 months ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

2 years ago

0.0.1

2 years ago