Client used for communication with Apple Music API.
ProtectedctxProtectedenvPrivateinInternal registry tracking active, ongoing fetch operations within this DO instance.
Client 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.
Internal
— Do not use directly. This is an escape hatch for frameworks (like Agents) that receive calls via native DO RPC, bypassing the standard fetch/alarm/webSocket entry points where initialization normally happens. Calling this from application code is unsupported and may break without notice.
Send a message to all connected clients, except connection ids listed in without
Optionalwithout: string[]PrivatecacheCaches a fetch response asynchronously while streaming the body content directly to the client. Also prevents redundant fetches during concurrent requests
The target URL key for the Cache API storage.
An asynchronous supplier returning the underlying network Response.
A Promise resolving to a Response object suitable for immediate streaming.
OptionalconnectPrivatecreateCreates a new SongGuessServer Durable Object by generating a unique ID and then returning the room data.
A Promise that resolves with a standard Response object.
PrivatefetchPrivatefetchPrivategenerateGenerates a unique 6-character room ID that does not currently exist.
A Promise that resolves with the unique 6-character room ID, or null if a unique ID couldn't be found after 100 attempts.
Get 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
PrivategetFetches playlist information from an Apple Music URL.
The Apple Music URL of the playlist.
A Promise resolving to the Playlist information.
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>PrivatesearchPrivatesearchEstablish 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>PrivatesongFetches a song from Apple Music API using its ISRC.
the ISRC to look for.
A promise that resolves to a JSON song object or null if not found.
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.