-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
32 lines (27 loc) · 895 Bytes
/
main.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
require('dotenv').config();
const express = require('express')
const Mux = require('@mux/mux-node');
const { Video } = new Mux(process.env.MUX_TOKEN_ID, process.env.MUX_TOKEN_SECRET);
const app = express()
const port = 3000
app.get('/live-streams', async (req, res) => {
const liveStreams = await Video.LiveStreams.list();
res.json(liveStreams.map((liveStream) => ({
id: liveStream.id,
status: liveStream.status,
playback_ids: liveStream.playback_ids,
created_at: liveStream.created_at
})));
});
app.get('/assets', async (req, res) => {
const Assets = await Video.Assets.list();
res.json(Assets.map((asset) => ({
id: asset.id,
status: asset.status,
playback_ids: asset.playback_ids,
created_at: asset.created_at
})));
});
app.listen(port, () => {
console.log(`Mux API listening on port ${port}`)
})