Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
app.post('/api/get-token', function (req, res) {
// The video-call to connect
var sessionName = req.body.sessionName;
// Role associated to this user
var role = OpenViduRole.PUBLISHER;
console.log("Getting a token | {sessionName}={" + sessionName + "}");
// Build tokenOptions object with PUBLISHER role
var tokenOptions = {
role: role
}
if (mapSessions[sessionName]) {
// Session already exists
console.log('Existing session ' + sessionName);
// Get the existing Session from the collection
var mySession = mapSessions[sessionName];
// Generate a new token asynchronously with the recently created tokenOptions
// Listen (start app with node server.js)
var options = {
key: fs.readFileSync('openvidukey.pem'),
cert: fs.readFileSync('openviducert.pem')
};
https.createServer(options, app).listen(5000);
// Mock database
var users = [{
user: "publisher1",
pass: "pass",
role: OpenViduRole.PUBLISHER
}, {
user: "publisher2",
pass: "pass",
role: OpenViduRole.PUBLISHER
}, {
user: "subscriber",
pass: "pass",
role: OpenViduRole.SUBSCRIBER
}];
// Environment variable: URL where our OpenVidu server is listening
var OPENVIDU_URL = process.argv[2];
// Environment variable: secret shared with our OpenVidu server
var OPENVIDU_SECRET = process.argv[3];
// Entrypoint to OpenVidu Node Client SDK
var OV = new OpenVidu(OPENVIDU_URL, OPENVIDU_SECRET);
// Collection to pair session names with OpenVidu Session objects
var mapSessions = {};
type: 'application/vnd.api+json'
})); // Parse application/vnd.api+json as json
app.set('view engine', 'ejs'); // Embedded JavaScript as template engine
// Listen (start app with node server.js)
var options = {
key: fs.readFileSync('openvidukey.pem'),
cert: fs.readFileSync('openviducert.pem')
};
https.createServer(options, app).listen(5000);
// Mock database
var users = [{
user: "publisher1",
pass: "pass",
role: OpenViduRole.PUBLISHER
}, {
user: "publisher2",
pass: "pass",
role: OpenViduRole.PUBLISHER
}, {
user: "subscriber",
pass: "pass",
role: OpenViduRole.SUBSCRIBER
}];
// Environment variable: URL where our OpenVidu server is listening
var OPENVIDU_URL = process.argv[2];
// Environment variable: secret shared with our OpenVidu server
var OPENVIDU_SECRET = process.argv[3];
// Entrypoint to OpenVidu Node Client SDK
// Listen (start app with node server.js)
var options = {
key: fs.readFileSync('openvidukey.pem'),
cert: fs.readFileSync('openviducert.pem')
};
https.createServer(options, app).listen(5000);
// Mock database
var users = [{
user: "publisher1",
pass: "pass",
role: OpenViduRole.PUBLISHER
}, {
user: "publisher2",
pass: "pass",
role: OpenViduRole.PUBLISHER
}, {
user: "subscriber",
pass: "pass",
role: OpenViduRole.SUBSCRIBER
}];
// Environment variable: URL where our OpenVidu server is listening
var OPENVIDU_URL = process.argv[2];
// Environment variable: secret shared with our OpenVidu server
var OPENVIDU_SECRET = process.argv[3];
// Entrypoint to OpenVidu Node Client SDK
var OV = new OpenVidu(OPENVIDU_URL, OPENVIDU_SECRET);
// Collection to pair session names with OpenVidu Session objects
var mapSessions = {};
app.use(bodyParser.json({
type: 'application/vnd.api+json'
})); // Parse application/vnd.api+json as json
// Listen (start app with node server.js)
var options = {
key: fs.readFileSync('openvidukey.pem'),
cert: fs.readFileSync('openviducert.pem')
};
https.createServer(options, app).listen(5000);
// Mock database
var users = [{
user: "publisher1",
pass: "pass",
role: OpenViduRole.PUBLISHER
}, {
user: "publisher2",
pass: "pass",
role: OpenViduRole.PUBLISHER
}, {
user: "subscriber",
pass: "pass",
role: OpenViduRole.SUBSCRIBER
}];
// Environment variable: URL where our OpenVidu server is listening
var OPENVIDU_URL = process.argv[2];
// Environment variable: secret shared with our OpenVidu server
var OPENVIDU_SECRET = process.argv[3];
// Entrypoint to OpenVidu Node Client SDK