From dca5cdc48e872073ee2223f459c6f93a0e4ce22d Mon Sep 17 00:00:00 2001 From: pabloFuente Date: Fri, 10 May 2024 12:47:27 +0200 Subject: [PATCH] Update index.js for node tutorial --- application-server/node/index.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/application-server/node/index.js b/application-server/node/index.js index cf63a869..535b8d57 100644 --- a/application-server/node/index.js +++ b/application-server/node/index.js @@ -1,6 +1,6 @@ +import "dotenv/config"; import express from "express"; import cors from "cors"; -import "dotenv/config"; import { AccessToken } from "livekit-server-sdk"; const SERVER_PORT = process.env.SERVER_PORT || 6080; @@ -13,22 +13,22 @@ app.use(cors()); app.use(express.json()); app.post("/token", async (req, res) => { - const roomName = req.body.roomName; - const participantName = req.body.participantName; + const roomName = req.body.roomName; + const participantName = req.body.participantName; - if (!roomName || !participantName) { - res.status(400).json("roomName and participantName are required"); - return; - } + if (!roomName || !participantName) { + res.status(400).json("roomName and participantName are required"); + return; + } - const at = new AccessToken(LIVEKIT_API_KEY, LIVEKIT_API_SECRET, { - identity: participantName - }); - at.addGrant({ roomJoin: true, room: roomName }); - const token = await at.toJwt(); - res.json(token); + const at = new AccessToken(LIVEKIT_API_KEY, LIVEKIT_API_SECRET, { + identity: participantName, + }); + at.addGrant({ roomJoin: true, room: roomName }); + const token = await at.toJwt(); + res.json(token); }); app.listen(SERVER_PORT, () => { - console.log("Server started on port:", SERVER_PORT); + console.log("Server started on port:", SERVER_PORT); });