2020-11-27 17:09:36 +01:00
|
|
|
import * as cors from 'cors'
|
2020-09-17 09:20:52 +02:00
|
|
|
import * as express from 'express'
|
|
|
|
import { mapToJSON } from '@server/helpers/core-utils'
|
2021-06-16 15:14:41 +02:00
|
|
|
import { LiveSegmentShaStore } from '@server/lib/live'
|
2020-12-07 14:32:36 +01:00
|
|
|
import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
|
2020-09-17 09:20:52 +02:00
|
|
|
|
|
|
|
const liveRouter = express.Router()
|
|
|
|
|
|
|
|
liveRouter.use('/segments-sha256/:videoUUID',
|
2020-11-27 17:09:36 +01:00
|
|
|
cors(),
|
2020-09-17 09:20:52 +02:00
|
|
|
getSegmentsSha256
|
|
|
|
)
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
|
|
|
liveRouter
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
function getSegmentsSha256 (req: express.Request, res: express.Response) {
|
|
|
|
const videoUUID = req.params.videoUUID
|
|
|
|
|
2021-06-16 15:14:41 +02:00
|
|
|
const result = LiveSegmentShaStore.Instance.getSegmentsSha256(videoUUID)
|
2020-09-17 09:20:52 +02:00
|
|
|
|
|
|
|
if (!result) {
|
2021-06-01 01:36:53 +02:00
|
|
|
return res.status(HttpStatusCode.NOT_FOUND_404).end()
|
2020-09-17 09:20:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return res.json(mapToJSON(result))
|
|
|
|
}
|