diff --git a/backend/openapi/components/responses/success-create-room.yaml b/backend/openapi/components/responses/success-create-room.yaml index 145a7c0..3215f44 100644 --- a/backend/openapi/components/responses/success-create-room.yaml +++ b/backend/openapi/components/responses/success-create-room.yaml @@ -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 diff --git a/backend/openapi/paths/rooms.yaml b/backend/openapi/paths/rooms.yaml index ac57a2a..04ba240 100644 --- a/backend/openapi/paths/rooms.yaml +++ b/backend/openapi/paths/rooms.yaml @@ -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' diff --git a/backend/src/controllers/room.controller.ts b/backend/src/controllers/room.controller.ts index c427288..b88a0a3 100644 --- a/backend/src/controllers/room.controller.ts +++ b/backend/src/controllers/room.controller.ts @@ -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); diff --git a/backend/tests/utils/helpers.ts b/backend/tests/utils/helpers.ts index f01f693..2c4a310 100644 --- a/backend/tests/utils/helpers.ts +++ b/backend/tests/utils/helpers.ts @@ -154,7 +154,7 @@ export const createRoom = async (options: MeetRoomOptions = {}): Promise