-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
46 lines (38 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
var express = require('express');
var router = express.Router();
const path = require('path');
const kaltura = require('kaltura-client');
var KalturaClientFactory = require('../lib/kalturaClientFactory');
/* GET home page. */
router.get('/', async function (req, res, next) {
try {
var appName = 'analyticsviewer';
/* used to designate your application name, this can be used in the Analytics
later to differentiate usage across different apps
(such as website vs. mobile iOS vs. mobile Android vs. partner site)*/
var appDomain = process.env.APP_DOMAIN; // the domain to track this playback session to
var privileges = 'appid:'+appName+'-'+appDomain+',setrole:KMC_ANALYTICS_ROLE';
var adminks = await KalturaClientFactory.getKS(process.env.KALTURA_USER_ID, {
type: kaltura.enums.SessionType.ADMIN,
privileges: privileges
});
res.render('index', { ks: adminks });
} catch (e) {
res.render('error', { message: e, error: e });
}
});
router.get('/*', async function (req, res, next) {
try {
var appName = 'analyticsviewer';
var privileges = 'appid:'+appName+'-'+appDomain+',setrole:KMC_ANALYTICS_ROLE';
var appDomain = process.env.APP_DOMAIN; // the domain to track this playback session to
var adminks = await KalturaClientFactory.getKS(process.env.KALTURA_USER_ID, {
type: kaltura.enums.SessionType.ADMIN,
privileges: privileges
});
res.render(path.parse(req.path).name,{ ks: adminks });
} catch (e) {
res.render('error', { message: e, error: e });
}
});
module.exports = router;