Improved node application server
This commit is contained in:
parent
94ace9e355
commit
dc1edc5b5b
@ -1,3 +1,4 @@
|
||||
SERVER_PORT=5000
|
||||
LIVEKIT_URL=ws://localhost:7880/
|
||||
LIVEKIT_API_KEY=devkey
|
||||
LIVEKIT_API_SECRET=secret
|
||||
@ -40,8 +40,16 @@ server.listen(SERVER_PORT, () => {
|
||||
app.post('/token', (req, res) => {
|
||||
const roomName = req.body.roomName;
|
||||
const participantName = req.body.participantName;
|
||||
|
||||
if (!roomName || !participantName) {
|
||||
res.status(400).send('roomName and participantName are required');
|
||||
return;
|
||||
}
|
||||
|
||||
const at = new AccessToken(LIVEKIT_API_KEY, LIVEKIT_API_SECRET, {
|
||||
identity: participantName,
|
||||
// add metadata to the token, which will be available in the participant's metadata
|
||||
metadata: JSON.stringify({ livekitUrl: process.env.LIVEKIT_URL }),
|
||||
});
|
||||
at.addGrant({ roomJoin: true, room: roomName });
|
||||
const token = at.toJwt();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user