Node.js SDK
Clients initialization
An example of a class that initializes clients and is exported in a single tone
import { ChannelClient, ParticipantClient } from 'livelists-node-js';
class LiveListsClient {
constructor() {
this.channel = new ChannelClient({
apiHost: "https://livelists.tech/livelists-twirp/",
apiKey: "apiKey",
secretKey: "secretKey"
})
this.participant = new ParticipantClient({
apiHost: "https://livelists.tech/livelists-twirp/",
apiKey: "apiKey",
secretKey: "secretKey"
})
}
public channel:ChannelClient
public participant:ParticipantClient
}
export const LiveLists = new LiveListsClient()
ChannelClient
createChannel
const {
identifier,
customData,
createdAt,
maxParticipants
} = await LiveLists.channel.createChannel({
identifier: 'id',
maxParticipants: 100,
customData: {
channelName: ""
}
});
ParticipantClient
addParticipantToChannel
const {
accessToken,
participant,
grants
} = await LiveLists.participant.addParticipantToChannel({
identifier: token,
channelId: "chat._id",
grants: {
admin: true,
readMessages: true,
sendMessage: true,
},
customData: {
username: randomName,
}
});
getAccessToken
const {
accessToken,
identifier,
channelId
} = await LiveLists.participant.getAccessToken({
identifier: token,
channelId: "chat._id"
});