@eslym/sveltekit-adapter-bun 2.1.1 → 2.1.2

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/README.md CHANGED
@@ -193,6 +193,10 @@ export type PreCompressOptions = {
193
193
  | `HTTP_OVERRIDE_ORIGIN` | Force the request origin when it is unable to retrieve from the request | - |
194
194
  | `HTTP_IDLE_TIMEOUT` | The request timeout for the server(in seconds) | `30` |
195
195
  | `HTTP_MAX_BODY` | The maximum body size for the request | `128mib` |
196
+ | `TLS_CERT_FILE` | Path to the TLS certificate file (PEM). Enables HTTPS when set alongside `TLS_KEY_FILE` | - |
197
+ | `TLS_KEY_FILE` | Path to the TLS private key file (PEM). Required with `TLS_CERT_FILE` to enable HTTPS | - |
198
+ | `TLS_CA_FILE` | Optional path to a CA bundle file (PEM) | - |
199
+ | `TLS_PASSPHRASE` | Optional passphrase for an encrypted `TLS_KEY_FILE` | - |
196
200
  | `WS_IDLE_TIMEOUT` | The websocket idle timeout (in seconds) | `120` |
197
201
  | `WS_MAX_PAYLOAD` | The maximum payload size for the websocket | `16mib` |
198
202
  | `WS_NO_PING` | Disable automatic ping response | `false` |
@@ -520,9 +520,30 @@ function websocketOptions() {
520
520
  sendPings: !bool_env("WS_NO_PING")
521
521
  };
522
522
  }
523
+ function tlsOptions() {
524
+ const cert = get_env("TLS_CERT_FILE");
525
+ const key = get_env("TLS_KEY_FILE");
526
+ if (!cert || !key) {
527
+ if (cert || key) {
528
+ console.warn("[adapter-bun] TLS_CERT_FILE and TLS_KEY_FILE must both be set. TLS disabled.");
529
+ }
530
+ return {};
531
+ }
532
+ const ca = get_env("TLS_CA_FILE");
533
+ const passphrase = get_env("TLS_PASSPHRASE");
534
+ return {
535
+ tls: {
536
+ cert: Bun.file(cert),
537
+ key: Bun.file(key),
538
+ ...ca ? { ca: Bun.file(ca) } : {},
539
+ ...passphrase ? { passphrase } : {}
540
+ }
541
+ };
542
+ }
523
543
  function serve() {
524
544
  const server2 = Bun.serve({
525
545
  ...serveOptions(),
546
+ ...tlsOptions(),
526
547
  fetch: create_fetch({
527
548
  overrideOrigin: get_env("HTTP_OVERRIDE_ORIGIN"),
528
549
  hostHeader: get_env("HTTP_HOST_HEADER"),
@@ -545,6 +566,7 @@ if (Bun.main === Bun.fileURLToPath(import.meta.url)) {
545
566
  export {
546
567
  websocketOptions,
547
568
  websocketHandler,
569
+ tlsOptions,
548
570
  serveOptions,
549
571
  serve,
550
572
  create_fetch as createBunFetch
package/package.json CHANGED
@@ -38,5 +38,5 @@
38
38
  "@rollup/plugin-node-resolve": "^15.3.1",
39
39
  "rollup": "^4.55.3"
40
40
  },
41
- "version": "2.1.1"
41
+ "version": "2.1.2"
42
42
  }