Client used for communication with Apple Music API.
ProtectedctxProtectedenvClient used for communication with SoundCloud API.
StaticoptionsThe name for this server.
Resolves from this.ctx.id.name — the native DO id name, populated
whenever the stub was created via idFromName() or getByName().
This is available inside every entry point (including the constructor,
alarms, and hibernating websocket handlers).
For alarm handlers firing on stale on-disk alarm records from
older workerd versions that didn't persist name into the alarm
record, the name is recovered from a storage fallback record.
Throws if neither source is available — typically this means the DO
was addressed via idFromString() or newUniqueId(), which is not
supported by PartyServer.
Send a message to all connected clients, except connection ids listed in without
Optionalwithout: string[]OptionalconnectGet a connection by connection id
Get all connections. Optionally, you can provide a tag to filter returned connections.
Use Server#getConnectionTags to tag the connection on connect.
Optionaltag: stringYou can tag a connection to filter them in Server#getConnections. Each connection supports up to 9 tags, each tag max length is 256 characters.
Returns the current this.ctx
Called when a new connection is made to the server.
Called when an error occurs on a connection.
Called when an exception occurs.
The error that occurred.
Called when a message is received from a connection.
Called when the server is started for the first time.
Optionalprops: Record<string, unknown>Establish this server's name and trigger onStart().
Use cases:
ctx.id.name is
undefined — e.g. DOs addressed via idFromString() /
newUniqueId(). setName() stashes the name in memory and
persists it under __ps_name so cold-wake invocations
recover it via #ensureInitialized()'s legacy fallback.props to onStart() via the
optional second argument.For DOs addressed via idFromName() / getByName(), calling
setName() is redundant — this.name is available automatically
from ctx.id.name. The normal initialization path also persists
a fallback record so old-compat alarm handlers can recover the name.
Throws if name does not match ctx.id.name.
Not appropriate for facets. Cloudflare Agents and any other
framework using ctx.facets.get(...) should pass an explicit
id in FacetStartupOptions so the facet has its own
ctx.id.name:
const stub = ctx.facets.get(facetKey, () => ({
class: ChildClass,
id: ctx.exports.SomeBoundDOClass.idFromName(facetName),
}));
Without an explicit id, the facet inherits the parent DO's
ctx.id (including ctx.id.name), and setName() will throw
the ctx.id.name-mismatch error because the facet's intended
name differs from the parent's. See
https://developers.cloudflare.com/dynamic-workers/usage/durable-object-facets/
for the FacetStartupOptions.id semantics.
Optionalprops: Record<string, unknown>Execute SQL queries against the Server's database
Type of the returned rows
SQL query template strings
Values to be inserted into the query
Array of query results
Handles API requests to the /api/{endpoint} endpoints.