aboutsummaryrefslogtreecommitdiff
path: root/docs/api/tcp.md
diff options
context:
space:
mode:
authorGravatar Colin McDonnell <colinmcd94@gmail.com> 2023-05-29 11:49:51 -0700
committerGravatar GitHub <noreply@github.com> 2023-05-29 11:49:51 -0700
commit9b6913e1a674ceb7f670f917fc355bb8758c6c72 (patch)
tree9ff0bb4a8c22f8f9505242e5f0e6e40e795da0df /docs/api/tcp.md
parente2de1f5c133ed3aac6fcea7e8e7c5fcd771d65f9 (diff)
downloadbun-9b6913e1a674ceb7f670f917fc355bb8758c6c72.tar.gz
bun-9b6913e1a674ceb7f670f917fc355bb8758c6c72.tar.zst
bun-9b6913e1a674ceb7f670f917fc355bb8758c6c72.zip
More/better docs for JSX, utils, binary data, streams, hashing, `bun test`, `Bun.serve` (#3005)
* WIP * Updates * Document deepEquals * WIP * Update typeS * Update TLS docs for Bun.serve * Update types for tls * Draft binary data page. Add Streams page. * Update test runner docs * Add hashing, flesh out utils * Grammar * Update types * Fix * Add import.meta docs * Tee
Diffstat (limited to 'docs/api/tcp.md')
-rw-r--r--docs/api/tcp.md33
1 files changed, 29 insertions, 4 deletions
diff --git a/docs/api/tcp.md b/docs/api/tcp.md
index cb6d2d783..bcf86d9a8 100644
--- a/docs/api/tcp.md
+++ b/docs/api/tcp.md
@@ -59,7 +59,7 @@ Bun.listen<SocketData>({
});
```
-To enable TLS, pass a `tls` object containing `keyFile` and `certFile` properties.
+To enable TLS, pass a `tls` object containing `key` and `cert` fields.
```ts
Bun.listen({
@@ -69,13 +69,38 @@ Bun.listen({
data(socket, data) {},
},
tls: {
- certFile: "cert.pem",
- keyFile: "key.pem",
+ // can be string, BunFile, TypedArray, Buffer, or array thereof
+ key: Bun.file("./key.pem"),
+ cert: Bun.file("./cert.pem"),
},
});
```
-The result of `Bun.listen` is a server that conforms to the `TCPSocket` instance.
+{% callout %}
+
+**Note** — Earlier versions of Bun supported passing a file path as `keyFile` and `certFile`; this has been deprecated as of `v0.6.3`.
+
+{% /callout %}
+
+The `key` and `cert` fields expect the _contents_ of your TLS key and certificate. This can be a string, `BunFile`, `TypedArray`, or `Buffer`.
+
+```ts
+Bun.listen({
+ // ...
+ tls: {
+ // BunFile
+ key: Bun.file("./key.pem"),
+ // Buffer
+ key: fs.readFileSync("./key.pem"),
+ // string
+ key: fs.readFileSync("./key.pem", "utf8"),
+ // array of above
+ key: [Bun.file('./key1.pem'), Bun.file('./key2.pem']
+ },
+});
+```
+
+The result of `Bun.listen` is a server that conforms to the `TCPSocket` interface.
```ts
const server = Bun.listen({