-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
57 lines (48 loc) · 1.56 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
var
http = require("http")
, fs = require("fs")
, express = require("express")
, express = require("express")
, morgan = require('morgan')
, CineIO = require('cine-io')
, keys = require('./fetch_api_keys_from_environment')()
// CINE IO API KEYS
, publicKey = keys.publicKey
, secretKey = keys.secretKey
, client = CineIO.init({secretKey: secretKey})
, app = express()
, port, httpServer
;
app.use(morgan("dev"));
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.get('', function(req, res) {
var identity, options;
if (!publicKey && !secretKey){
return res.render('not_configured', {title: 'Not Configured'});
}
options = {
title: 'Functionality Example',
publicKey: publicKey,
room: req.param('room'),
call: req.param('call')
};
if (identity = req.param('identity')) {
// NOTE: PROVIDING A SECURE IDENTITY VIA PARAMS IS ONLY FOR DEMONSTRATION PURPOSES
// only provide secure identities via proper authentication to your system
// (i.e. via your application's login)
// then provide your user with a secure identity which is valid for only that user.
options.identity = client.peer.generateIdentitySignature(identity);
}
if (options.room || options.identity) {
res.render('index', options);
} else {
res.render('use_cases', options);
}
});
app.use(express.static(__dirname + "/public"));
port = process.env.PORT || 9090;
httpServer = http.createServer(app);
httpServer.listen(port, function() {
return console.log("HTTP server started at http://localhost:" + port);
});