From c9dfdd8852338e1a9c4c8515351411f763cc6d4e Mon Sep 17 00:00:00 2001 From: Carlos Santos <4a.santos@gmail.com> Date: Fri, 21 Mar 2025 16:31:15 +0100 Subject: [PATCH] backend: Introduce internal API routes for participants and recordings with updated base path --- backend/src/environment.ts | 1 + backend/src/routes/participants.routes.ts | 21 ++++++++++----------- backend/src/server.ts | 17 ++++++++++++----- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/backend/src/environment.ts b/backend/src/environment.ts index dcd6489..582ba1f 100644 --- a/backend/src/environment.ts +++ b/backend/src/environment.ts @@ -63,6 +63,7 @@ export const { } = process.env; export const MEET_API_BASE_PATH = '/meet/api'; +export const MEET_INTERNAL_API_BASE_PATH_V1 = '/meet/internal-api/v1'; export const MEET_API_BASE_PATH_V1 = MEET_API_BASE_PATH + '/v1'; export const PARTICIPANT_TOKEN_COOKIE_NAME = 'OvMeetParticipantToken'; export const ACCESS_TOKEN_COOKIE_NAME = 'OvMeetAccessToken'; diff --git a/backend/src/routes/participants.routes.ts b/backend/src/routes/participants.routes.ts index 05b79d6..855b634 100644 --- a/backend/src/routes/participants.routes.ts +++ b/backend/src/routes/participants.routes.ts @@ -6,19 +6,18 @@ import { validateParticipantTokenRequest } from '../middlewares/request-validators/participant-validator.middleware.js'; -export const participantsInternalRouter = Router(); -participantsInternalRouter.use(bodyParser.urlencoded({ extended: true })); -participantsInternalRouter.use(bodyParser.json()); +export const internalParticipantsRouter = Router(); +internalParticipantsRouter.use(bodyParser.urlencoded({ extended: true })); +internalParticipantsRouter.use(bodyParser.json()); -participantsInternalRouter.post('/token', validateParticipantTokenRequest, participantCtrl.generateParticipantToken); -participantsInternalRouter.post( +internalParticipantsRouter.post('/token', validateParticipantTokenRequest, participantCtrl.generateParticipantToken); +internalParticipantsRouter.post( '/token/refresh', validateParticipantTokenRequest, participantCtrl.refreshParticipantToken ); - -export const participantsRouter = Router(); -participantsRouter.use(bodyParser.urlencoded({ extended: true })); -participantsRouter.use(bodyParser.json()); - -participantsRouter.delete('/:participantName', validateParticipantDeletionRequest, participantCtrl.deleteParticipant); +internalParticipantsRouter.delete( + '/:participantName', + validateParticipantDeletionRequest, + participantCtrl.deleteParticipant +); diff --git a/backend/src/server.ts b/backend/src/server.ts index fa102e6..ed11b99 100644 --- a/backend/src/server.ts +++ b/backend/src/server.ts @@ -7,12 +7,19 @@ import { SERVER_CORS_ORIGIN, logEnvVars, MEET_API_BASE_PATH_V1, - MEET_API_BASE_PATH + MEET_INTERNAL_API_BASE_PATH_V1 } from './environment.js'; import { openapiHtmlPath, indexHtmlPath, publicFilesPath, webcomponentBundlePath } from './utils/path-utils.js'; -import { authRouter, livekitRouter, preferencesRouter, recordingRouter, roomRouter } from './routes/index.js'; +import { + authRouter, + internalRecordingRouter, + livekitRouter, + preferencesRouter, + recordingRouter, + roomRouter +} from './routes/index.js'; import { GlobalPreferencesService, RoomService } from './services/index.js'; -import { participantsInternalRouter, participantsRouter } from './routes/participants.routes.js'; +import { internalParticipantsRouter } from './routes/participants.routes.js'; import cookieParser from 'cookie-parser'; const createApp = () => { @@ -37,13 +44,13 @@ const createApp = () => { app.use(`${MEET_API_BASE_PATH_V1}/rooms`, /*mediaTypeValidatorMiddleware,*/ roomRouter); app.use(`${MEET_API_BASE_PATH_V1}/recordings`, /*mediaTypeValidatorMiddleware,*/ recordingRouter); app.use(`${MEET_API_BASE_PATH_V1}/auth`, /*mediaTypeValidatorMiddleware,*/ authRouter); - app.use(`${MEET_API_BASE_PATH_V1}/participants`, participantsRouter); // TODO: This route should be part of the rooms router app.use(`${MEET_API_BASE_PATH_V1}/preferences`, /*mediaTypeValidatorMiddleware,*/ preferencesRouter); // Internal routes - app.use(`${MEET_API_BASE_PATH}/participants`, participantsInternalRouter); + app.use(`${MEET_INTERNAL_API_BASE_PATH_V1}/participants`, internalParticipantsRouter); + app.use(`${MEET_INTERNAL_API_BASE_PATH_V1}/recordings`, internalRecordingRouter); app.use('/meet/health', (_req: Request, res: Response) => res.status(200).send('OK')); app.use('/livekit/webhook', livekitRouter);