live.ts 826 B

1234567891011121314151617181920212223242526272829303132
  1. import cors from 'cors'
  2. import express from 'express'
  3. import { mapToJSON } from '@server/helpers/core-utils'
  4. import { LiveSegmentShaStore } from '@server/lib/live'
  5. import { HttpStatusCode } from '@shared/models'
  6. const liveRouter = express.Router()
  7. liveRouter.use('/segments-sha256/:videoUUID',
  8. cors(),
  9. getSegmentsSha256
  10. )
  11. // ---------------------------------------------------------------------------
  12. export {
  13. liveRouter
  14. }
  15. // ---------------------------------------------------------------------------
  16. function getSegmentsSha256 (req: express.Request, res: express.Response) {
  17. const videoUUID = req.params.videoUUID
  18. const result = LiveSegmentShaStore.Instance.getSegmentsSha256(videoUUID)
  19. if (!result) {
  20. return res.status(HttpStatusCode.NOT_FOUND_404).end()
  21. }
  22. return res.json(mapToJSON(result))
  23. }