aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/live.ts
blob: cfb4741b727c3c9cfac23a55393569213a61c462 (plain) (blame)
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
import * as cors from 'cors'
import * as express from 'express'
import { mapToJSON } from '@server/helpers/core-utils'
import { LiveManager } from '@server/lib/live-manager'
import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'

const liveRouter = express.Router()

liveRouter.use('/segments-sha256/:videoUUID',
  cors(),
  getSegmentsSha256
)

// ---------------------------------------------------------------------------

export {
  liveRouter
}

// ---------------------------------------------------------------------------

function getSegmentsSha256 (req: express.Request, res: express.Response) {
  const videoUUID = req.params.videoUUID

  const result = LiveManager.Instance.getSegmentsSha256(videoUUID)

  if (!result) {
    return res.status(HttpStatusCode.NOT_FOUND_404).end()
  }

  return res.json(mapToJSON(result))
}