From 2207b7651fc0e22892ea7f7f36a312adf38d0d53 Mon Sep 17 00:00:00 2001 From: Carlos Santos <4a.santos@gmail.com> Date: Tue, 15 Apr 2025 12:41:04 +0200 Subject: [PATCH] backend: Update startRecording response to include Location header and change status code to 201 --- .../responses/internal/success-start-recording.yaml | 7 +++++++ backend/openapi/paths/internal/recordings.yaml | 2 +- backend/src/controllers/recording.controller.ts | 9 +++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/backend/openapi/components/responses/internal/success-start-recording.yaml b/backend/openapi/components/responses/internal/success-start-recording.yaml index 70fd2c5..3c090c2 100644 --- a/backend/openapi/components/responses/internal/success-start-recording.yaml +++ b/backend/openapi/components/responses/internal/success-start-recording.yaml @@ -9,3 +9,10 @@ content: status: 'STARTING' filename: 'room-123--XX445.mp4' startDate: 1600000000000 +headers: + Location: + description: URL of the newly created recording + schema: + type: string + format: uri + example: https://your-api.com/meet/internal-api/v1/recordings/room-123--EG_XYZ--XX445 diff --git a/backend/openapi/paths/internal/recordings.yaml b/backend/openapi/paths/internal/recordings.yaml index f14d999..11d2bf7 100644 --- a/backend/openapi/paths/internal/recordings.yaml +++ b/backend/openapi/paths/internal/recordings.yaml @@ -11,7 +11,7 @@ requestBody: $ref: '../../components/requestBodies/start-recording-request.yaml' responses: - '200': + '201': $ref: '../../components/responses/internal/success-start-recording.yaml' '401': $ref: '../../components/responses/unauthorized-error.yaml' diff --git a/backend/src/controllers/recording.controller.ts b/backend/src/controllers/recording.controller.ts index 81f2726..a70116f 100644 --- a/backend/src/controllers/recording.controller.ts +++ b/backend/src/controllers/recording.controller.ts @@ -3,6 +3,7 @@ import { LoggerService } from '../services/logger.service.js'; import { OpenViduMeetError } from '../models/error.model.js'; import { RecordingService } from '../services/recording.service.js'; import { container } from '../config/dependency-injector.config.js'; +import INTERNAL_CONFIG from '../config/internal-config.js'; export const startRecording = async (req: Request, res: Response) => { const logger = container.get(LoggerService); @@ -12,7 +13,12 @@ export const startRecording = async (req: Request, res: Response) => { try { const recordingInfo = await recordingService.startRecording(roomId); - return res.status(200).json(recordingInfo); + res.setHeader( + 'Location', + `${req.protocol}://${req.get('host')}/${INTERNAL_CONFIG.INTERNAL_API_BASE_PATH_V1}/recordings/${recordingInfo.recordingId}` + ); + + return res.status(201).json(recordingInfo); } catch (error) { if (error instanceof OpenViduMeetError) { logger.error(`Error starting recording: ${error.message}`); @@ -181,5 +187,4 @@ export const getRecordingMedia = async (req: Request, res: Response) => { } }; - // Internal Recording methods