@ngrok/ngrok 0.5.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -28
- package/CODE_OF_CONDUCT.md +45 -0
- package/Cargo.toml +5 -2
- package/README.md +161 -21
- package/docs/assets/highlight.css +13 -6
- package/docs/assets/search.js +1 -1
- package/docs/classes/NgrokHttpTunnelBuilder.html +25 -22
- package/docs/classes/NgrokLabeledTunnelBuilder.html +8 -5
- package/docs/classes/NgrokSession.html +24 -9
- package/docs/classes/NgrokSessionBuilder.html +20 -17
- package/docs/classes/NgrokTcpTunnelBuilder.html +12 -9
- package/docs/classes/NgrokTlsTunnelBuilder.html +14 -11
- package/docs/classes/NgrokTunnel.html +21 -35
- package/docs/classes/UpdateRequest.html +7 -4
- package/docs/functions/authtoken.html +5 -2
- package/docs/functions/connect.html +5 -2
- package/docs/functions/consoleLog.html +5 -2
- package/docs/functions/disconnect.html +5 -2
- package/docs/functions/getTunnel.html +88 -0
- package/docs/functions/getTunnelByUrl.html +88 -0
- package/docs/functions/kill.html +5 -2
- package/docs/functions/listen.html +5 -2
- package/docs/functions/listenable.html +5 -2
- package/docs/functions/loggingCallback.html +5 -2
- package/docs/functions/tunnels.html +83 -0
- package/docs/index.html +74 -13
- package/docs/interfaces/Config.html +57 -54
- package/docs/modules.html +7 -1
- package/examples/fastify/ngrok-fastify.js +1 -1
- package/examples/hapi/ngrok-hapi.js +1 -1
- package/examples/nestjs/src/main.ts +1 -1
- package/examples/nextjs/ngrok.config.js +1 -1
- package/examples/ngrok-connect-full.js +22 -23
- package/examples/ngrok-connect-minimal.js +3 -2
- package/examples/ngrok-http-full.js +1 -1
- package/examples/ngrok-http-minimum.js +1 -1
- package/examples/ngrok-labeled.js +1 -1
- package/examples/ngrok-tcp.js +1 -1
- package/examples/ngrok-tls.js +1 -1
- package/examples/ngrok-typescript.ts +1 -1
- package/examples/ngrok-windows-pipe.js +1 -1
- package/examples/remix/ngrok.config.js +1 -1
- package/examples/svelte/ngrok.config.cjs +1 -1
- package/examples/vue/ngrok.config.ts +1 -1
- package/index.d.ts +12 -6
- package/index.js +89 -23
- package/package.json +14 -14
- package/scripts/gc-node-drop.js +1 -1
- package/scripts/gc-rust-drop.js +1 -1
- package/src/connect.rs +13 -8
- package/src/lib.rs +21 -0
- package/src/session.rs +17 -6
- package/src/tunnel.rs +139 -104
- package/src/tunnel_builder.rs +2 -2
- package/trailer.js +85 -22
package/CHANGELOG.md
CHANGED
|
@@ -1,75 +1,83 @@
|
|
|
1
|
+
## 0.6.0:
|
|
2
|
+
|
|
3
|
+
- Flattened `tunnel.forwardPipe()` and `tunnel.forwardTcp()` into `tunnel.forward()`. Determination will be made based on `addr` input.
|
|
4
|
+
- Add `ngrok.tunnels()` and `session.tunnels()` to get a list of current non-closed tunnels for the process or session, respectively.
|
|
5
|
+
- Add `errorCode` field to thrown errors, where possible.
|
|
6
|
+
- More heuristics for automatic unix socket file placement.
|
|
7
|
+
- Connect heuristic improved for strings parseable as numbers.
|
|
8
|
+
|
|
1
9
|
## 0.5.2:
|
|
2
10
|
|
|
3
|
-
|
|
11
|
+
- Cleanly return from a tunnel forward call after a `session.close()`.
|
|
4
12
|
|
|
5
13
|
## 0.5.1:
|
|
6
14
|
|
|
7
|
-
|
|
15
|
+
- `consoleLog` return signature.
|
|
8
16
|
|
|
9
17
|
## 0.5.0:
|
|
10
18
|
|
|
11
|
-
|
|
12
|
-
|
|
19
|
+
- Add `NgrokSession.clientInfo()`.
|
|
20
|
+
- Rename to `ngrok-nodejs`.
|
|
13
21
|
|
|
14
22
|
## 0.4.1:
|
|
15
23
|
|
|
16
|
-
|
|
17
|
-
|
|
24
|
+
- Clean shutdown when run from npm.
|
|
25
|
+
- Unblock Svelte postinstall script.
|
|
18
26
|
|
|
19
27
|
## 0.4.0:
|
|
20
28
|
|
|
21
|
-
|
|
22
|
-
|
|
29
|
+
- Move to a single tunnel type for simplicity.
|
|
30
|
+
- Documentation updates.
|
|
23
31
|
|
|
24
32
|
## 0.3.0:
|
|
25
33
|
|
|
26
|
-
|
|
27
|
-
|
|
34
|
+
- Added `ngrok.connect(Config)`, `ngrok.authtoken()`, and `ngrok.disconnect(url)`.
|
|
35
|
+
- Examples cleanup.
|
|
28
36
|
|
|
29
37
|
## 0.2.0:
|
|
30
38
|
|
|
31
|
-
|
|
32
|
-
|
|
39
|
+
- Now have examples for Express, Fastify, Hapi, Koa, Nest.js, Next.js, Remix, Svelte, and Vue.
|
|
40
|
+
- Add `prettier` auto code formatting.
|
|
33
41
|
|
|
34
42
|
## 0.1.1:
|
|
35
43
|
|
|
36
|
-
|
|
37
|
-
|
|
44
|
+
- Bump `ngrok-rust` to `0.11.3`.
|
|
45
|
+
- Migrate `ca_cert` to the upstream call in `ngrok-rust`.
|
|
38
46
|
|
|
39
47
|
## 0.1.0:
|
|
40
48
|
|
|
41
|
-
|
|
49
|
+
- Added `ca_cert`, `handle_heartbeat`, and `handle_disconnection` to NgrokSession.
|
|
42
50
|
|
|
43
51
|
## 0.0.12:
|
|
44
52
|
|
|
45
|
-
|
|
46
|
-
|
|
53
|
+
- Added NgrokSession.close().
|
|
54
|
+
- Cleanly shutdown when listen is called with a pre-configured tunnel.
|
|
47
55
|
|
|
48
56
|
## 0.0.11:
|
|
49
57
|
|
|
50
|
-
|
|
58
|
+
- Cleanly shutdown on all platforms when there are callbacks registered.
|
|
51
59
|
|
|
52
60
|
## 0.0.10:
|
|
53
61
|
|
|
54
|
-
|
|
62
|
+
- Child client versioning support.
|
|
55
63
|
|
|
56
64
|
## 0.0.9:
|
|
57
65
|
|
|
58
|
-
|
|
66
|
+
- Support for named pipes on Windows.
|
|
59
67
|
|
|
60
68
|
## 0.0.8:
|
|
61
69
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
70
|
+
- Support callbacks for logging, include console.log and Winston handlers.
|
|
71
|
+
- Can now pass tunnels directly to net.Server.listen().
|
|
72
|
+
- Clean shutdown on SIGINT after ngrok.listen(server).
|
|
73
|
+
- Typedoc generation of documentation.
|
|
66
74
|
|
|
67
75
|
## 0.0.7:
|
|
68
76
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
77
|
+
- Improved memory management, removing need to keep NodeJS from garbage collecting certain objects.
|
|
78
|
+
- Support callbacks for remote operations (stop, restart, update).
|
|
79
|
+
- Typescript support for getSocket and listen.
|
|
72
80
|
|
|
73
81
|
## 0.0.6:
|
|
74
82
|
|
|
75
|
-
|
|
83
|
+
- Initial public release.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# ngrok Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
|
6
|
+
|
|
7
|
+
## Our Standards
|
|
8
|
+
|
|
9
|
+
Examples of behavior that contributes to creating a positive environment include:
|
|
10
|
+
|
|
11
|
+
- Using welcoming and inclusive language
|
|
12
|
+
- Being respectful of differing viewpoints and experiences
|
|
13
|
+
- Gracefully accepting constructive criticism
|
|
14
|
+
- Focusing on what is best for the community
|
|
15
|
+
- Showing empathy towards other community members
|
|
16
|
+
|
|
17
|
+
Examples of unacceptable behavior by participants include:
|
|
18
|
+
|
|
19
|
+
- The use of sexualized language or imagery and unwelcome sexual attention or advances
|
|
20
|
+
- Trolling, insulting/derogatory comments, and personal or political attacks
|
|
21
|
+
- Public or private harassment
|
|
22
|
+
- Publishing others' private information, such as a physical or electronic address, without explicit permission
|
|
23
|
+
- Other conduct which could reasonably be considered inappropriate in a professional setting
|
|
24
|
+
|
|
25
|
+
## Our Responsibilities
|
|
26
|
+
|
|
27
|
+
The ngrok documentation team is responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
|
28
|
+
|
|
29
|
+
The ngrok documentation team has the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
|
30
|
+
|
|
31
|
+
## Scope
|
|
32
|
+
|
|
33
|
+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the ngrok docs project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
|
34
|
+
|
|
35
|
+
## Enforcement
|
|
36
|
+
|
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [support@ngrok.com](mailto:support@ngrok.com). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
|
38
|
+
|
|
39
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
|
40
|
+
|
|
41
|
+
## Attribution
|
|
42
|
+
|
|
43
|
+
This Code of Conduct is adapted from the Contributor Covenant, version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
|
44
|
+
|
|
45
|
+
For answers to common questions about this code of conduct, see https://www.contributor-covenant.org/faq
|
package/Cargo.toml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
edition = "2021"
|
|
3
3
|
name = "ngrok-nodejs"
|
|
4
|
-
version = "0.
|
|
4
|
+
version = "0.6.0"
|
|
5
5
|
|
|
6
6
|
[lib]
|
|
7
7
|
crate-type = ["cdylib"]
|
|
@@ -11,10 +11,13 @@ async-rustls = { version = "0.3.0" }
|
|
|
11
11
|
async-trait = "0.1.59"
|
|
12
12
|
bytes = "1.3.0"
|
|
13
13
|
lazy_static = "1.4.0"
|
|
14
|
+
# pin mio until all dependencies are also on windows-sys 0.48
|
|
15
|
+
# https://github.com/microsoft/windows-rs/issues/2410#issuecomment-1490802715
|
|
16
|
+
mio = { version = "=0.8.6" }
|
|
14
17
|
# Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix
|
|
15
18
|
napi = { version = "2.12.1", default-features = false, features = ["napi4", "tokio_rt"] }
|
|
16
19
|
napi-derive = "2.12.1"
|
|
17
|
-
ngrok = { version = "0.
|
|
20
|
+
ngrok = { version = "0.13.1" }
|
|
18
21
|
parking_lot = "0.12.1"
|
|
19
22
|
rustls-pemfile = "1.0.1"
|
|
20
23
|
tokio = { version = "1.23.0", features = ["sync"] }
|
package/README.md
CHANGED
|
@@ -24,47 +24,170 @@ This is the ngrok agent in library form, suitable for integrating directly into
|
|
|
24
24
|
applications. This allows you to quickly build ngrok into your application with no separate process
|
|
25
25
|
to manage.
|
|
26
26
|
|
|
27
|
-
#
|
|
27
|
+
# Documentation
|
|
28
|
+
|
|
29
|
+
A quickstart guide and a full API reference are included in the [ngrok-nodejs API documentation](https://ngrok.github.io/ngrok-nodejs/).
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
# Quickstart
|
|
32
|
+
|
|
33
|
+
1. Install the `ngrok-nodejs` package from
|
|
34
|
+
[npm](https://www.npmjs.com/package/@ngrok/ngrok):
|
|
31
35
|
|
|
32
36
|
```shell
|
|
33
37
|
npm install @ngrok/ngrok
|
|
34
38
|
```
|
|
35
39
|
|
|
36
|
-
|
|
40
|
+
2. After you've installed the package, you'll need an authtoken. Retrieve one on the
|
|
41
|
+
[authtoken page of your ngrok dashboard](https://dashboard.ngrok.com/get-started/your-authtoken)
|
|
37
42
|
|
|
38
|
-
|
|
43
|
+
3. Add the following code block using the [connect method](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/ngrok-connect-minimal.js) to expose your nodejs application at port `8080` on `localhost`:
|
|
39
44
|
|
|
40
|
-
|
|
45
|
+
```jsx
|
|
46
|
+
const ngrok = require("@ngrok/ngrok");
|
|
47
|
+
(async function() {
|
|
48
|
+
const url = await ngrok.connect({ addr: 8080, authtoken_from_env: true });
|
|
49
|
+
console.log(`Ingress established at: ${url}`);
|
|
50
|
+
})();
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
You can find more examples in [the /examples directory](https://github.com/ngrok/ngrok-nodejs/tree/main/examples).
|
|
54
|
+
|
|
55
|
+
## Authorization
|
|
41
56
|
|
|
42
|
-
|
|
43
|
-
[Auth Token page of your ngrok dashboard](https://dashboard.ngrok.com/get-started/your-authtoken)
|
|
57
|
+
To use most of ngrok's features, you'll need an authtoken. To obtain one, sign up for free at [ngrok.com](https://dashboard.ngrok.com/signup) and retrieve it from the [authtoken page of your ngrok dashboard](https://dashboard.ngrok.com/get-started/your-authtoken). Once you have copied your authtoken, you can reference it in several ways.
|
|
44
58
|
|
|
45
|
-
|
|
46
|
-
A minimal use-case looks like [the following](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/ngrok-http-minimum.js):
|
|
59
|
+
You can set it in the `NGROK_AUTHTOKEN` environment variable and pass `authtoken_from_env: true` to the [connect](https://ngrok.github.io/ngrok-nodejs/functions/connect.html) method:
|
|
47
60
|
|
|
48
61
|
```jsx
|
|
49
|
-
|
|
62
|
+
await ngrok.connect({authtoken_from_env: true, ...});
|
|
63
|
+
```
|
|
50
64
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
65
|
+
Or pass the authtoken directly to the [connect](https://ngrok.github.io/ngrok-nodejs/functions/connect.html) method:
|
|
66
|
+
|
|
67
|
+
```jsx
|
|
68
|
+
await ngrok.connect({authtoken: token, ...});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Or set it for all connections with the [authtoken](https://ngrok.github.io/ngrok-nodejs/functions/authtoken.html) method:
|
|
72
|
+
|
|
73
|
+
```jsx
|
|
74
|
+
await ngrok.authtoken(token);
|
|
57
75
|
```
|
|
58
76
|
|
|
59
|
-
|
|
77
|
+
## Connection
|
|
78
|
+
|
|
79
|
+
The [connect](https://ngrok.github.io/ngrok-nodejs/functions/connect.html) method is the easiest way to start an ngrok session and establish a tunnel to a specified address. The [connect](https://ngrok.github.io/ngrok-nodejs/functions/connect.html) method returns a promise that resolves to the public URL of the tunnel.
|
|
80
|
+
|
|
81
|
+
With no arguments the [connect](https://ngrok.github.io/ngrok-nodejs/functions/connect.html) method will start an HTTP tunnel to `localhost` port `80`:
|
|
60
82
|
|
|
61
83
|
```jsx
|
|
62
84
|
const ngrok = require("@ngrok/ngrok");
|
|
63
|
-
|
|
64
|
-
console.log(
|
|
85
|
+
(async function() {
|
|
86
|
+
console.log( await ngrok.connect() );
|
|
87
|
+
})();
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
You can pass the port number to forward on `localhost`:
|
|
91
|
+
|
|
92
|
+
```jsx
|
|
93
|
+
const url = await ngrok.connect(4242);
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Or you can specify the host and port via a string:
|
|
97
|
+
|
|
98
|
+
```jsx
|
|
99
|
+
const url = await ngrok.connect("localhost:4242");
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
More options can be passed to the `connect` method to customize the connection:
|
|
103
|
+
|
|
104
|
+
```jsx
|
|
105
|
+
const url = await ngrok.connect({addr: 8080, basic_auth: "ngrok:online1line"});
|
|
106
|
+
const url = await ngrok.connect({addr: 8080, oauth_provider: "google", oauth_allow_domains: "example.com"});
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The (optional) `proto` parameter is the tunnel type, which defaults to `http`. To create a TCP tunnel:
|
|
110
|
+
|
|
111
|
+
```jsx
|
|
112
|
+
const url = await ngrok.connect({proto: 'tcp', addr: 25565});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Disconnection
|
|
116
|
+
|
|
117
|
+
To close a tunnel use the [disconnect](https://ngrok.github.io/ngrok-nodejs/functions/disconnect.html) method with the `url` of the tunnel to close:
|
|
118
|
+
|
|
119
|
+
```jsx
|
|
120
|
+
await ngrok.disconnect(url);
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Or omit the `url` to close all tunnels:
|
|
124
|
+
|
|
125
|
+
```jsx
|
|
126
|
+
await ngrok.disconnect();
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
The [close](https://ngrok.github.io/ngrok-nodejs/classes/NgrokTunnel.html#close) method on a tunnel will shut it down, and also stop the ngrok session if it is no longer needed. This method returns a promise that resolves when the tunnel is closed.
|
|
130
|
+
|
|
131
|
+
```jsx
|
|
132
|
+
const tunnel = await ngrok.getTunnelByUrl(url);
|
|
133
|
+
await tunnel.close();
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Listing Tunnels
|
|
137
|
+
|
|
138
|
+
To list all current non-closed tunnels use the [tunnels](https://ngrok.github.io/ngrok-nodejs/functions/tunnels.html) method:
|
|
139
|
+
|
|
140
|
+
```jsx
|
|
141
|
+
const tunnels = await ngrok.tunnels();
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
# Full Configuration
|
|
145
|
+
|
|
146
|
+
This example shows [all the possible configuration items of ngrok.connect](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/ngrok-connect-full.js):
|
|
147
|
+
|
|
148
|
+
```jsx
|
|
149
|
+
const url = await ngrok.connect({
|
|
150
|
+
// session configuration
|
|
151
|
+
addr: `localhost:8080`, // or `8080` or `pipe:${UNIX_SOCKET}`
|
|
152
|
+
authtoken: "<authtoken>",
|
|
153
|
+
authtoken_from_env: true,
|
|
154
|
+
on_status_change: (addr, error) => {
|
|
155
|
+
console.log(`disconnected, addr ${addr} error: ${error}`);
|
|
156
|
+
},
|
|
157
|
+
session_metadata: "Online in One Line",
|
|
158
|
+
// tunnel configuration
|
|
159
|
+
basic_auth: ["ngrok:online1line"],
|
|
160
|
+
circuit_breaker: 0.1,
|
|
161
|
+
compression: true,
|
|
162
|
+
domain: "<domain>",
|
|
163
|
+
ip_restriction_allow_cidrs: ["0.0.0.0/0"],
|
|
164
|
+
ip_restriction_deny_cidrs: ["10.1.1.1/32"],
|
|
165
|
+
metadata: "example tunnel metadata from nodejs",
|
|
166
|
+
mutual_tls_cas: [fs.readFileSync('ca.crt', 'utf8')],
|
|
167
|
+
oauth_provider: "google",
|
|
168
|
+
oauth_allow_domains: ["<domain>"],
|
|
169
|
+
oauth_allow_emails: ["<email>"],
|
|
170
|
+
oauth_scopes: ["<scope>"],
|
|
171
|
+
oidc_issuer_url: "<url>",
|
|
172
|
+
oidc_client_id: "<id>",
|
|
173
|
+
oidc_client_secret: "<secret>",
|
|
174
|
+
oidc_allow_domains: ["<domain>"],
|
|
175
|
+
oidc_allow_emails: ["<email>"],
|
|
176
|
+
oidc_scopes: ["<scope>"],
|
|
177
|
+
proxy_proto: "", // One of: "", "1", "2"
|
|
178
|
+
request_header_remove: ["X-Req-Nope"],
|
|
179
|
+
response_header_remove: ["X-Res-Nope"],
|
|
180
|
+
request_header_add: ["X-Req-Yup:true"],
|
|
181
|
+
response_header_add: ["X-Res-Yup:true"],
|
|
182
|
+
schemes: ["HTTPS"],
|
|
183
|
+
verify_webhook_provider: "twilio",
|
|
184
|
+
verify_webhook_secret: "asdf",
|
|
185
|
+
websocket_tcp_converter: true,
|
|
65
186
|
});
|
|
66
187
|
```
|
|
67
188
|
|
|
189
|
+
The [Config](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html) interface also shows all the available options.
|
|
190
|
+
|
|
68
191
|
# Examples
|
|
69
192
|
|
|
70
193
|
Degit can be used for cloning and running an example directory like this:
|
|
@@ -78,8 +201,8 @@ For example:
|
|
|
78
201
|
npx degit github:ngrok/ngrok-nodejs/examples/express express && cd express && npm i
|
|
79
202
|
```
|
|
80
203
|
|
|
81
|
-
|
|
82
204
|
## Frameworks
|
|
205
|
+
* [AWS App Runner](https://aws.amazon.com/apprunner/) - See the [ngrok SDK Serverless Example](https://github.com/ngrok/ngrok-sdk-serverless-example) repository
|
|
83
206
|
* [Express](https://expressjs.com/) - [Quickstart Example](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/express/ngrok-express-quickstart.js), [Configuration Example](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/express/ngrok-express.js)
|
|
84
207
|
* [Fastify](https://www.fastify.io/) - [Example](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/fastify/ngrok-fastify.js)
|
|
85
208
|
* [Hapi](https://hapi.dev/) - [Example](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/hapi/ngrok-hapi.js)
|
|
@@ -100,6 +223,23 @@ npx degit github:ngrok/ngrok-nodejs/examples/express express && cd express && np
|
|
|
100
223
|
* TLS - [Example](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/ngrok-tls.js)
|
|
101
224
|
* Windows Pipe - [Example](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/ngrok-windows-pipe.js)
|
|
102
225
|
|
|
226
|
+
# Builders
|
|
227
|
+
|
|
228
|
+
For more control over Sessions and Tunnels, the builder classes can be used.
|
|
229
|
+
|
|
230
|
+
A minimal example using the builder class looks like [the following](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/ngrok-http-minimum.js):
|
|
231
|
+
|
|
232
|
+
```jsx
|
|
233
|
+
async function create_tunnel() {
|
|
234
|
+
const session = await new ngrok.NgrokSessionBuilder().authtokenFromEnv().connect();
|
|
235
|
+
const tunnel = await session.httpEndpoint().listen();
|
|
236
|
+
console.log("Ingress established at:", tunnel.url());
|
|
237
|
+
tunnel.forward("localhost:8081");
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
See here for a [Full Configuration Example](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/ngrok-http-full.js)
|
|
242
|
+
|
|
103
243
|
# Async Programming
|
|
104
244
|
|
|
105
245
|
All methods return a `Promise` and are suitable for use in asynchronous
|
|
@@ -5,16 +5,18 @@
|
|
|
5
5
|
--dark-hl-1: #CE9178;
|
|
6
6
|
--light-hl-2: #0000FF;
|
|
7
7
|
--dark-hl-2: #569CD6;
|
|
8
|
-
--light-hl-3: #
|
|
9
|
-
--dark-hl-3: #
|
|
8
|
+
--light-hl-3: #0070C1;
|
|
9
|
+
--dark-hl-3: #4FC1FF;
|
|
10
10
|
--light-hl-4: #795E26;
|
|
11
11
|
--dark-hl-4: #DCDCAA;
|
|
12
|
-
--light-hl-5: #
|
|
13
|
-
--dark-hl-5: #
|
|
14
|
-
--light-hl-6: #
|
|
15
|
-
--dark-hl-6: #
|
|
12
|
+
--light-hl-5: #AF00DB;
|
|
13
|
+
--dark-hl-5: #C586C0;
|
|
14
|
+
--light-hl-6: #001080;
|
|
15
|
+
--dark-hl-6: #9CDCFE;
|
|
16
16
|
--light-hl-7: #098658;
|
|
17
17
|
--dark-hl-7: #B5CEA8;
|
|
18
|
+
--light-hl-8: #008000;
|
|
19
|
+
--dark-hl-8: #6A9955;
|
|
18
20
|
--light-code-background: #FFFFFF;
|
|
19
21
|
--dark-code-background: #1E1E1E;
|
|
20
22
|
}
|
|
@@ -28,6 +30,7 @@
|
|
|
28
30
|
--hl-5: var(--light-hl-5);
|
|
29
31
|
--hl-6: var(--light-hl-6);
|
|
30
32
|
--hl-7: var(--light-hl-7);
|
|
33
|
+
--hl-8: var(--light-hl-8);
|
|
31
34
|
--code-background: var(--light-code-background);
|
|
32
35
|
} }
|
|
33
36
|
|
|
@@ -40,6 +43,7 @@
|
|
|
40
43
|
--hl-5: var(--dark-hl-5);
|
|
41
44
|
--hl-6: var(--dark-hl-6);
|
|
42
45
|
--hl-7: var(--dark-hl-7);
|
|
46
|
+
--hl-8: var(--dark-hl-8);
|
|
43
47
|
--code-background: var(--dark-code-background);
|
|
44
48
|
} }
|
|
45
49
|
|
|
@@ -52,6 +56,7 @@
|
|
|
52
56
|
--hl-5: var(--light-hl-5);
|
|
53
57
|
--hl-6: var(--light-hl-6);
|
|
54
58
|
--hl-7: var(--light-hl-7);
|
|
59
|
+
--hl-8: var(--light-hl-8);
|
|
55
60
|
--code-background: var(--light-code-background);
|
|
56
61
|
}
|
|
57
62
|
|
|
@@ -64,6 +69,7 @@
|
|
|
64
69
|
--hl-5: var(--dark-hl-5);
|
|
65
70
|
--hl-6: var(--dark-hl-6);
|
|
66
71
|
--hl-7: var(--dark-hl-7);
|
|
72
|
+
--hl-8: var(--dark-hl-8);
|
|
67
73
|
--code-background: var(--dark-code-background);
|
|
68
74
|
}
|
|
69
75
|
|
|
@@ -75,4 +81,5 @@
|
|
|
75
81
|
.hl-5 { color: var(--hl-5); }
|
|
76
82
|
.hl-6 { color: var(--hl-6); }
|
|
77
83
|
.hl-7 { color: var(--hl-7); }
|
|
84
|
+
.hl-8 { color: var(--hl-8); }
|
|
78
85
|
pre, code { background: var(--code-background); }
|