backend: Rename streamRecording to getRecordingContent and update route for streaming recordings

This commit is contained in:
Carlos Santos 2025-04-07 18:28:58 +02:00
parent 546e17f1e5
commit bb54cd6c8e
2 changed files with 20 additions and 4 deletions

View File

@ -126,8 +126,14 @@ export const deleteRecording = async (req: Request, res: Response) => {
} }
}; };
// Internal Recording methods /**
export const streamRecording = async (req: Request, res: Response) => { * Streams a recording video file to the client with support for range requests.
*
* This controller endpoint retrieves a recording by its ID and streams it as a video/mp4 file.
* It supports HTTP range requests, allowing for features like video seeking and partial downloads.
*
*/
export const getRecordingContent = async (req: Request, res: Response) => {
const logger = container.get(LoggerService); const logger = container.get(LoggerService);
const recordingId = req.params.recordingId; const recordingId = req.params.recordingId;
@ -172,3 +178,6 @@ export const streamRecording = async (req: Request, res: Response) => {
return res.status(500).json({ name: 'Recording Error', message: 'Unexpected error streaming recording' }); return res.status(500).json({ name: 'Recording Error', message: 'Unexpected error streaming recording' });
} }
}; };
// Internal Recording methods

View File

@ -61,14 +61,21 @@ recordingRouter.delete(
recordingCtrl.bulkDeleteRecordings recordingCtrl.bulkDeleteRecordings
); );
recordingRouter.get(
'/:recordingId/content',
withAuth(apiKeyValidator, tokenAndRoleValidator(UserRole.ADMIN)),
withValidRecordingId,
recordingCtrl.getRecordingContent
);
// Internal Recording Routes // Internal Recording Routes
export const internalRecordingRouter = Router(); export const internalRecordingRouter = Router();
internalRecordingRouter.use(bodyParser.urlencoded({ extended: true })); internalRecordingRouter.use(bodyParser.urlencoded({ extended: true }));
internalRecordingRouter.use(bodyParser.json()); internalRecordingRouter.use(bodyParser.json());
internalRecordingRouter.get( internalRecordingRouter.get(
'/:recordingId/stream', '/:recordingId/content',
withAuth(tokenAndRoleValidator(UserRole.ADMIN)), withAuth(tokenAndRoleValidator(UserRole.ADMIN)),
withValidRecordingId, withValidRecordingId,
recordingCtrl.streamRecording recordingCtrl.getRecordingContent
); );