Skip to main content

Interface: Server

An HTTP server instance.

Properties

port

readonly port: number

The port the server is listening on.

Methods

close()

close(): void

Close the server.

Returns

void


upgrade()

upgrade(request, options?): boolean

Upgrade an HTTP request to a WebSocket connection. Must be called synchronously inside the fetch handler.

Parameters

request

Request

The incoming request with an Upgrade: websocket header.

options?

UpgradeOptions

Options for the WebSocket connection.

Returns

boolean

true if the upgrade was successful, false otherwise.