Skip to content

Commit 2a0dcb9

Browse files
committed
refactor(Connection)!: rename ConnectionOptions to BuiltInConnectionOptions
1 parent ab8423b commit 2a0dcb9

File tree

6 files changed

+20
-17
lines changed

6 files changed

+20
-17
lines changed

docs/src/components/connection-options.mdx renamed to docs/src/components/built-in-connection-options.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import StatusCodeDescription from './status-code-description.mdx'
22
import HeadersDescription from './headers-description.mdx'
33

4-
`options` is a `ConnectionOptions` object with the following properties:
4+
`options` is a `BuiltInConnectionOptions` object with the following properties:
55

66
|Property|Type|Default|Description|
77
|-|-|-|-|

docs/src/content/docs/reference/api.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ next: false
99
---
1010

1111
import {Aside} from "@astrojs/starlight/components";
12-
import ConnectionOptions from "../../../components/connection-options.mdx";
12+
import BuiltInConnectionsOptions from "../../../components/built-in-connection-options.mdx";
1313
import StatusCodeDescription from "../../../components/status-code-description.mdx";
1414
import HeadersDescription from "../../../components/headers-description.mdx";
1515

@@ -401,7 +401,7 @@ Represents an SSE-related error thrown from within Better SSE.
401401
402402
A `Connection` represents the underlying connection that a [`Session`](#sessionstate) manages, abstracting away the differences between the [Node HTTP/1](https://nodejs.org/docs/latest/api/http.html), [Node HTTP/2](https://nodejs.org/docs/latest/api/http2.html), [Fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) and any other APIs.
403403
404-
You can implement your own custom `Connection` subclass to make Better SSE compatible with any framework.
404+
You can implement your own custom `Connection` subclass to make Better SSE compatible with any framework not already supported by the built-in connection types.
405405
406406
#### `Connection#url`: `URL`
407407
@@ -457,38 +457,38 @@ Perform any necessary cleanup after the connection is closed.
457457
458458
The in-built `NodeHttp1Connection` represents a connection based on the Node [HTTP/1 API](https://nodejs.org/docs/latest/api/http.html).
459459
460-
#### `new NodeHttp1Connection(req: IncomingMessage, res: ServerResponse[, options: ConnectionOptions])`
460+
#### `new NodeHttp1Connection(req: IncomingMessage, res: ServerResponse[, options: BuiltInConnectionsOptions])`
461461
462462
`req` is an instance of [IncomingMessage](https://nodejs.org/api/http.html#http_class_http_incomingmessage).
463463
464464
`res` is an instance of [ServerResponse](https://nodejs.org/api/http.html#http_class_http_serverresponse).
465465
466-
<ConnectionOptions />
466+
<BuiltInConnectionsOptions />
467467
468468
### `NodeHttp2CompatConnection`
469469
470470
*Extends from [Connection](#connection).*
471471
472472
The in-built `NodeHttp2CompatConnection` represents a connection based on the Node [HTTP/2 Compatibility API](https://nodejs.org/docs/latest/api/http2.html#compatibility-api).
473473
474-
#### `new NodeHttp2CompatConnection(req: Http2ServerRequest, res: Http2ServerResponse[, options: ConnectionOptions])`
474+
#### `new NodeHttp2CompatConnection(req: Http2ServerRequest, res: Http2ServerResponse[, options: BuiltInConnectionsOptions])`
475475
476476
`req` is an instance of [Http2ServerRequest](https://nodejs.org/api/http2.html#class-http2http2serverrequest).
477477
478478
`res` is an instance of [Http2ServerResponse](https://nodejs.org/api/http2.html#class-http2http2serverresponse).
479479
480-
<ConnectionOptions />
480+
<BuiltInConnectionsOptions />
481481
482482
### `FetchConnection`
483483
484484
*Extends from [Connection](#connection).*
485485
486486
The in-built `FetchConnection` represents a connection based on the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API).
487487
488-
#### `new FetchConnection(req: Request[, res: Response][, options: ConnectionOptions])`
488+
#### `new FetchConnection(req: Request[, res: Response][, options: BuiltInConnectionsOptions])`
489489
490490
`req` is an instance of [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request).
491491
492492
`res` is an instance of [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response), if given.
493493
494-
<ConnectionOptions />
494+
<BuiltInConnectionsOptions />

src/adapters/Connection.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,11 @@ abstract class Connection {
7373
abstract cleanup(): void;
7474
}
7575

76-
interface ConnectionOptions
76+
/**
77+
* Options passed from `Session` `options` argument to the built-in `Connection` implementations.
78+
*/
79+
interface BuiltInConnectionOptions
7780
extends Pick<SessionOptions, "statusCode" | "headers"> {}
7881

79-
export type {ConnectionOptions};
82+
export type {BuiltInConnectionOptions};
8083
export {Connection};

src/adapters/FetchConnection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
DEFAULT_RESPONSE_CODE,
33
DEFAULT_RESPONSE_HEADERS,
44
} from "../utils/constants";
5-
import {Connection, type ConnectionOptions} from "./Connection";
5+
import {Connection, type BuiltInConnectionOptions} from "./Connection";
66

77
class FetchConnection extends Connection {
88
private static encoder = new TextEncoder();
@@ -15,7 +15,7 @@ class FetchConnection extends Connection {
1515
constructor(
1616
request: Request,
1717
response: Response | null,
18-
options: ConnectionOptions = {}
18+
options: BuiltInConnectionOptions = {}
1919
) {
2020
super();
2121

src/adapters/NodeHttp1Connection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
DEFAULT_RESPONSE_CODE,
66
DEFAULT_RESPONSE_HEADERS,
77
} from "../utils/constants";
8-
import {Connection, type ConnectionOptions} from "./Connection";
8+
import {Connection, type BuiltInConnectionOptions} from "./Connection";
99

1010
class NodeHttp1Connection extends Connection {
1111
private controller: AbortController;
@@ -17,7 +17,7 @@ class NodeHttp1Connection extends Connection {
1717
constructor(
1818
private req: IncomingMessage,
1919
private res: ServerResponse,
20-
options: ConnectionOptions = {}
20+
options: BuiltInConnectionOptions = {}
2121
) {
2222
super();
2323

src/adapters/NodeHttp2CompatConnection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
DEFAULT_RESPONSE_CODE,
66
DEFAULT_RESPONSE_HEADERS,
77
} from "../utils/constants";
8-
import {Connection, type ConnectionOptions} from "./Connection";
8+
import {Connection, type BuiltInConnectionOptions} from "./Connection";
99

1010
class NodeHttp2CompatConnection extends Connection {
1111
private controller: AbortController;
@@ -17,7 +17,7 @@ class NodeHttp2CompatConnection extends Connection {
1717
constructor(
1818
private req: Http2ServerRequest,
1919
private res: Http2ServerResponse,
20-
options: ConnectionOptions = {}
20+
options: BuiltInConnectionOptions = {}
2121
) {
2222
super();
2323

0 commit comments

Comments
 (0)