backend: Update startRecording response to include Location header and change status code to 201
This commit is contained in:
parent
0402f284e7
commit
2207b7651f
@ -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
|
||||
|
||||
@ -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'
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user