backend: Update createRoom to return 201 status on successful room creation
This commit is contained in:
parent
5c67f2a370
commit
a65018072a
@ -1,5 +1,12 @@
|
||||
description: Success response for creating a room
|
||||
description: Room created successfully
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '../schemas/meet-room.yaml'
|
||||
headers:
|
||||
Location:
|
||||
description: URL of the newly created room
|
||||
schema:
|
||||
type: string
|
||||
format: uri
|
||||
example: https://your-api.com/meet/api/v1/rooms/room-id-123
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
requestBody:
|
||||
$ref: '../components/requestBodies/create-room-request.yaml'
|
||||
responses:
|
||||
'200':
|
||||
'201':
|
||||
$ref: '../components/responses/success-create-room.yaml'
|
||||
'401':
|
||||
$ref: '../components/responses/unauthorized-error.yaml'
|
||||
|
||||
@ -4,6 +4,7 @@ import { LoggerService } from '../services/logger.service.js';
|
||||
import { OpenViduMeetError } from '../models/error.model.js';
|
||||
import { RoomService, ParticipantService } from '../services/index.js';
|
||||
import { MeetRoomFilters, MeetRoomOptions, MeetRoomRoleAndPermissions, ParticipantRole } from '@typings-ce';
|
||||
import INTERNAL_CONFIG from '../config/internal-config.js';
|
||||
|
||||
export const createRoom = async (req: Request, res: Response) => {
|
||||
const logger = container.get(LoggerService);
|
||||
@ -15,7 +16,8 @@ export const createRoom = async (req: Request, res: Response) => {
|
||||
const baseUrl = `${req.protocol}://${req.get('host')}`;
|
||||
|
||||
const room = await roomService.createMeetRoom(baseUrl, options);
|
||||
return res.status(200).json(room);
|
||||
res.set('Location', `${baseUrl}${INTERNAL_CONFIG.API_BASE_PATH_V1}/rooms/${room.roomId}`);
|
||||
return res.status(201).json(room);
|
||||
} catch (error) {
|
||||
logger.error(`Error creating room with options '${JSON.stringify(options)}'`);
|
||||
handleError(res, error);
|
||||
|
||||
@ -154,7 +154,7 @@ export const createRoom = async (options: MeetRoomOptions = {}): Promise<MeetRoo
|
||||
.post(`${INTERNAL_CONFIG.API_BASE_PATH_V1}/rooms`)
|
||||
.set(INTERNAL_CONFIG.API_KEY_HEADER, MEET_API_KEY)
|
||||
.send(options)
|
||||
.expect(200);
|
||||
.expect(201);
|
||||
return response.body;
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user