This repository has been archived by the owner on Nov 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 83
/
index.js
112 lines (99 loc) · 2.62 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
const channels = require('express').Router();
channels.use('/zoom', require('./zoom'));
channels.use('/youtube', require('./youtube'));
const iconPrefix = '/static/channel-icons';
const configPatePathPrefix = '/captioner/settings/channels/new?type=';
const channelsList = [
{
id: 'dropbox',
name: 'Dropbox',
iconPath: `${iconPrefix}/dropbox.png`,
limit: 1,
configPagePath: `${configPatePathPrefix}dropbox`,
},
{
id: 'fab',
name: 'FAB Subtitler',
// iconPath: `${iconPrefix}/fab-subtitler.png`,
showNameWithIcon: true,
limit: 1,
configPagePath: `${configPatePathPrefix}fab`,
requiredExperiment: 'fab',
},
{
id: 'vmix',
name: 'vMix',
iconPath: `${iconPrefix}/vmix.png`,
limit: 1,
configPagePath: `${configPatePathPrefix}vmix`,
},
// {
// id: 'link',
// name: 'Link or Embed',
// iconName: 'link',
// limit: 1,
// configPagePath: `${configPatePathPrefix}link`,
// },
{
id: 'webhook',
name: 'Webhook',
iconName: 'plug',
limit: 1,
configPagePath: `${configPatePathPrefix}webhook`,
},
{
id: 'obs',
name: 'OBS Studio',
iconPath: `${iconPrefix}/obs.svg`,
showNameWithIcon: true,
limit: 1,
configPagePath: `${configPatePathPrefix}obs`,
},
{
id: 'zoom',
name: 'Zoom',
iconPath: `${iconPrefix}/zoom.png`,
limit: 1,
configPagePath: `${configPatePathPrefix}zoom`,
},
{
id: 'youtube',
name: 'YouTube',
iconPath: `${iconPrefix}/youtube.png`,
limit: 1,
configPagePath: `${configPatePathPrefix}youtube`,
requiredExperiment: 'youtube',
},
];
channels.get('/', async (req, res, next) => {
let { experiments } = req.query;
experiments = experiments ? String(experiments).split(',') : [];
let channelsToReturn = [
...channelsList.sort((a, b) =>
// Sort alphabetically by name
a.name.localeCompare(b.name)
),
].map((c) => ({ ...c })); // clone
// Filter out any channels that require experiments
// to be enabled, unless those experiments are enabled
channelsToReturn = channelsToReturn.filter(
(channel) =>
!channel.requiredExperiment ||
experiments.includes(channel.requiredExperiment)
);
channelsToReturn.forEach((channel) => delete channel.requiredExperiment);
res.send(channelsToReturn);
});
channels.get('/:id', async (req, res, next) => {
const { id } = req.params;
if (!id) {
return res.sendStatus(404);
}
const foundChannel = channelsList.find((channel) => channel.id === id);
if (foundChannel) {
res.send(foundChannel);
} else {
return res.sendStatus(404);
}
});
module.exports = channels;