1
0
Fork 0
peertube/server/controllers/live.ts

33 lines
836 B
TypeScript
Raw Normal View History

2020-11-27 16:09:36 +00:00
import * as cors from 'cors'
import * as express from 'express'
import { mapToJSON } from '@server/helpers/core-utils'
2021-06-16 13:14:41 +00:00
import { LiveSegmentShaStore } from '@server/lib/live'
2021-07-16 08:42:24 +00:00
import { HttpStatusCode } from '@shared/models'
const liveRouter = express.Router()
liveRouter.use('/segments-sha256/:videoUUID',
2020-11-27 16:09:36 +00:00
cors(),
getSegmentsSha256
)
// ---------------------------------------------------------------------------
export {
liveRouter
}
// ---------------------------------------------------------------------------
function getSegmentsSha256 (req: express.Request, res: express.Response) {
const videoUUID = req.params.videoUUID
2021-06-16 13:14:41 +00:00
const result = LiveSegmentShaStore.Instance.getSegmentsSha256(videoUUID)
if (!result) {
return res.status(HttpStatusCode.NOT_FOUND_404).end()
}
return res.json(mapToJSON(result))
}