diff options
author | 2022-10-26 21:04:12 -0700 | |
---|---|---|
committer | 2022-10-26 21:04:12 -0700 | |
commit | 75b1ef1ef4ea6a35d134e30e3c9723f9161fa140 (patch) | |
tree | 6bc4530606abb9f152f091b4b5c9f5983c87f960 /src/bun.js/api | |
parent | 830f83a44d2119846c0a64eb758f737b54a3e78b (diff) | |
download | bun-75b1ef1ef4ea6a35d134e30e3c9723f9161fa140.tar.gz bun-75b1ef1ef4ea6a35d134e30e3c9723f9161fa140.tar.zst bun-75b1ef1ef4ea6a35d134e30e3c9723f9161fa140.zip |
Make `"tls"` an explicit object we pass instead of implicit top-level options
cc @Electroid @colinhacks
Diffstat (limited to 'src/bun.js/api')
-rw-r--r-- | src/bun.js/api/bun/socket.zig | 12 | ||||
-rw-r--r-- | src/bun.js/api/server.zig | 22 |
2 files changed, 25 insertions, 9 deletions
diff --git a/src/bun.js/api/bun/socket.zig b/src/bun.js/api/bun/socket.zig index 6928f024e..38b6837b3 100644 --- a/src/bun.js/api/bun/socket.zig +++ b/src/bun.js/api/bun/socket.zig @@ -205,13 +205,15 @@ pub const SocketConfig = struct { var ssl: ?JSC.API.ServerConfig.SSLConfig = null; var default_data = JSValue.zero; - if (JSC.API.ServerConfig.SSLConfig.inJS(globalObject, opts, exception)) |ssl_config| { - ssl = ssl_config; - } else if (exception.* != null) { - return null; + if (opts.getTruthy(globalObject, "tls")) |tls| { + if (JSC.API.ServerConfig.SSLConfig.inJS(globalObject, tls, exception)) |ssl_config| { + ssl = ssl_config; + } else if (exception.* != null) { + return null; + } } - if (opts.getTruthy(globalObject, "hostname") orelse opts.getTruthy(globalObject, "host")) |hostname| { + if (opts.getTruthy(globalObject, "hostname")) |hostname| { if (hostname.isEmptyOrUndefinedOrNull() or !hostname.isString()) { exception.* = JSC.toInvalidArguments("Expected \"hostname\" to be a string", .{}, globalObject).asObjectRef(); return null; diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig index 73480a93d..c86edf534 100644 --- a/src/bun.js/api/server.zig +++ b/src/bun.js/api/server.zig @@ -329,12 +329,26 @@ pub const ServerConfig = struct { args.development = dev.toBoolean(); } - if (SSLConfig.fromJS(global, arguments, exception)) |ssl_config| { - args.ssl_config = ssl_config; + if (arg.getTruthy("tls")) |tls| { + if (SSLConfig.inJS(global, tls, exception)) |ssl_config| { + args.ssl_config = ssl_config; + } + + if (exception.* != null) { + return args; + } } - if (exception.* != null) { - return args; + // @compatibility Bun v0.x - v0.2.1 + // this used to be top-level, now it's "tls" object + if (args.ssl_config == null) { + if (SSLConfig.inJS(global, arg, exception)) |ssl_config| { + args.ssl_config = ssl_config; + } + + if (exception.* != null) { + return args; + } } if (arg.getTruthy(global, "maxRequestBodySize")) |max_request_body_size| { |