@arkstack/driver-h3 0.15.0 → 0.15.1

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.
Files changed (2) hide show
  1. package/dist/index.js +29 -4
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { t as staticAssetHandler } from "./middlewares-BORI5o6J.js";
2
2
  import { ArkstackKitDriver } from "@arkstack/contract";
3
3
  import { H3, HTTPResponse, serve, toResponse } from "h3";
4
- import { ErrorHandler, Logger, env, renderError, resolveRuntimeModule } from "@arkstack/common";
4
+ import { ErrorHandler, Logger, devTlsCredentials, env, localNetworkAddress, renderError, resolveRuntimeModule } from "@arkstack/common";
5
5
  import ngrok from "@ngrok/ngrok";
6
6
  import { resolveMiddleware } from "@arkstack/http";
7
7
  import { registerPlugin } from "resora";
@@ -181,13 +181,23 @@ var H3Driver = class extends ArkstackKitDriver {
181
181
  */
182
182
  async start(app, port) {
183
183
  const host = env("APP_HOST", env("HOST", "0.0.0.0"));
184
+ const secure = env("APP_SECURE", false) === true;
184
185
  const tunneled = env("TUNNEL", false);
185
- const server = await serve(app, {
186
+ const scheme = secure ? "https" : "http";
187
+ const tls = secure ? await devTlsCredentials() : void 0;
188
+ await serve(app, {
186
189
  port,
187
190
  hostname: host,
188
- silent: true
191
+ silent: true,
192
+ ...tls ? {
193
+ protocol: "https",
194
+ tls: {
195
+ cert: tls.cert,
196
+ key: tls.key
197
+ }
198
+ } : {}
189
199
  }).ready();
190
- let log = [Logger.log([["Server is running on", "white"], [server.url ?? `http://${host}:${port}`, "cyan"]], " ", false)];
200
+ let log = startupLogLines(scheme, host, port);
191
201
  if (tunneled === true) {
192
202
  const url = (await ngrok.forward({
193
203
  addr: port,
@@ -204,5 +214,20 @@ var H3Driver = class extends ArkstackKitDriver {
204
214
  console.log(log.join("\n"));
205
215
  }
206
216
  };
217
+ /**
218
+ * Build the "Server is running" startup lines, adding a local-network URL when
219
+ * the server is bound to all interfaces (`0.0.0.0`/`::`) so it is reachable from
220
+ * other devices.
221
+ */
222
+ const startupLogLines = (scheme, host, port) => {
223
+ const bindsAll = host === "0.0.0.0" || host === "::";
224
+ const localHost = bindsAll ? "localhost" : host;
225
+ const lines = [Logger.log([["Server is running on", "white"], [`${scheme}://${localHost}:${port}`, "cyan"]], " ", false)];
226
+ if (bindsAll) {
227
+ const address = localNetworkAddress();
228
+ if (address) lines.push(Logger.log([["Network access via", "white"], [`${scheme}://${address}:${port}`, "cyan"]], " ", false));
229
+ }
230
+ return lines;
231
+ };
207
232
  //#endregion
208
233
  export { H3Driver, H3EventResponse, Router, defaultErrorHandler };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkstack/driver-h3",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
4
4
  "type": "module",
5
5
  "description": "H3 driver for Arkstack, providing H3-based runtime integration for the framework.",
6
6
  "homepage": "https://arkstack.toneflix.net",
@@ -41,14 +41,14 @@
41
41
  "@resora/plugin-clear-router": "^1.0.66",
42
42
  "clear-router": "^2.9.0",
43
43
  "resora": "^1.3.27",
44
- "@arkstack/contract": "^0.15.0"
44
+ "@arkstack/contract": "^0.15.1"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "h3": "2.0.1-rc.22",
48
- "@arkstack/auth": "^0.15.0",
49
- "@arkstack/foundry": "^0.15.0",
50
- "@arkstack/inertia": "^0.15.0",
51
- "@arkstack/common": "^0.15.0"
48
+ "@arkstack/auth": "^0.15.1",
49
+ "@arkstack/common": "^0.15.1",
50
+ "@arkstack/foundry": "^0.15.1",
51
+ "@arkstack/inertia": "^0.15.1"
52
52
  },
53
53
  "peerDependenciesMeta": {
54
54
  "@arkstack/auth": {