TinyBasePartyKitServerConfig
{
storePath?: string;
messagePrefix?: string;
storagePrefix?: string;
responseHeaders?: HeadersInit;
}
Type | Description | |
---|---|---|
storePath? | string | The path used to set and get the whole |
messagePrefix? | string | The prefix at the beginning of the web socket messages between the client and the server when synchronizing the |
storagePrefix? | string | The prefix used before all the keys in the server's durable storage. Use this in case you are worried about the |
responseHeaders? | HeadersInit | An object containing the extra HTTP(S) headers returned to the client from this server. This defaults to the following three headers to allow CORS:
If you set this field, it will override the default completely. So, for example, if you add another header but still want the CORS defaults, you will need to explicitly set the Access-Control-Allow headers above again. |
The defaults (if used on both the server and client) will work fine, but if you are building more complex PartyKit apps and you need to configure path names, for example, then this is the type to use.
Example
When set as the config in a TinyBasePartyKitServer, this TinyBasePartyKitServerConfig
will expect clients to load and save their JSON serialization from and to an end point in the room called /my_tinybase
. Note that this would require you to also add the matching storePath setting to the PartyKitPersisterConfig
on the client side.
It will also store the data in the durable storage with a prefix of 'tinybase_' in case you are worried about colliding with other data stored in the room.
class MyServer extends TinyBasePartyKitServer {
readonly config = {
storePath: '/my_tinybase',
storagePrefix: 'tinybase_',
};
}
Since
v4.3.9