]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/controllers/live.ts
Refactor requests
[github/Chocobozzz/PeerTube.git] / server / controllers / live.ts
CommitLineData
4a7f9024 1import * as cors from 'cors'
c6c0fa6c
C
2import * as express from 'express'
3import { mapToJSON } from '@server/helpers/core-utils'
8ebf2a5d 4import { LiveSegmentShaStore } from '@server/lib/live'
c0e8b12e 5import { HttpStatusCode } from '@shared/models'
c6c0fa6c
C
6
7const liveRouter = express.Router()
8
9liveRouter.use('/segments-sha256/:videoUUID',
4a7f9024 10 cors(),
c6c0fa6c
C
11 getSegmentsSha256
12)
13
14// ---------------------------------------------------------------------------
15
16export {
17 liveRouter
18}
19
20// ---------------------------------------------------------------------------
21
22function getSegmentsSha256 (req: express.Request, res: express.Response) {
23 const videoUUID = req.params.videoUUID
24
8ebf2a5d 25 const result = LiveSegmentShaStore.Instance.getSegmentsSha256(videoUUID)
c6c0fa6c
C
26
27 if (!result) {
76148b27 28 return res.status(HttpStatusCode.NOT_FOUND_404).end()
c6c0fa6c
C
29 }
30
31 return res.json(mapToJSON(result))
32}