//native
type Ably = {
accessToken: string;
};
/**
* Creates a namespace
* Creates a namespace for the specified application ID.
*/
export async function main(
auth: Ably,
app_id: string,
body: {
id: string;
authenticated?: false | true;
persisted?: false | true;
persistLast?: false | true;
pushEnabled?: false | true;
batchingEnabled?: false | true;
batchingPolicy?: string;
batchingInterval?: number;
tlsOnly?: false | true;
exposeTimeserial?: false | true;
},
) {
const url = new URL(`https://control.ably.net/v1/apps/${app_id}/namespaces`);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.accessToken,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 185 days ago