backend: Introduce internal API routes for participants and recordings with updated base path

This commit is contained in:
Carlos Santos 2025-03-21 16:31:15 +01:00
parent ca348d1a47
commit c9dfdd8852
3 changed files with 23 additions and 16 deletions

View File

@ -63,6 +63,7 @@ export const {
} = process.env; } = process.env;
export const MEET_API_BASE_PATH = '/meet/api'; 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 MEET_API_BASE_PATH_V1 = MEET_API_BASE_PATH + '/v1';
export const PARTICIPANT_TOKEN_COOKIE_NAME = 'OvMeetParticipantToken'; export const PARTICIPANT_TOKEN_COOKIE_NAME = 'OvMeetParticipantToken';
export const ACCESS_TOKEN_COOKIE_NAME = 'OvMeetAccessToken'; export const ACCESS_TOKEN_COOKIE_NAME = 'OvMeetAccessToken';

View File

@ -6,19 +6,18 @@ import {
validateParticipantTokenRequest validateParticipantTokenRequest
} from '../middlewares/request-validators/participant-validator.middleware.js'; } from '../middlewares/request-validators/participant-validator.middleware.js';
export const participantsInternalRouter = Router(); export const internalParticipantsRouter = Router();
participantsInternalRouter.use(bodyParser.urlencoded({ extended: true })); internalParticipantsRouter.use(bodyParser.urlencoded({ extended: true }));
participantsInternalRouter.use(bodyParser.json()); internalParticipantsRouter.use(bodyParser.json());
participantsInternalRouter.post('/token', validateParticipantTokenRequest, participantCtrl.generateParticipantToken); internalParticipantsRouter.post('/token', validateParticipantTokenRequest, participantCtrl.generateParticipantToken);
participantsInternalRouter.post( internalParticipantsRouter.post(
'/token/refresh', '/token/refresh',
validateParticipantTokenRequest, validateParticipantTokenRequest,
participantCtrl.refreshParticipantToken participantCtrl.refreshParticipantToken
); );
internalParticipantsRouter.delete(
export const participantsRouter = Router(); '/:participantName',
participantsRouter.use(bodyParser.urlencoded({ extended: true })); validateParticipantDeletionRequest,
participantsRouter.use(bodyParser.json()); participantCtrl.deleteParticipant
);
participantsRouter.delete('/:participantName', validateParticipantDeletionRequest, participantCtrl.deleteParticipant);

View File

@ -7,12 +7,19 @@ import {
SERVER_CORS_ORIGIN, SERVER_CORS_ORIGIN,
logEnvVars, logEnvVars,
MEET_API_BASE_PATH_V1, MEET_API_BASE_PATH_V1,
MEET_API_BASE_PATH MEET_INTERNAL_API_BASE_PATH_V1
} from './environment.js'; } from './environment.js';
import { openapiHtmlPath, indexHtmlPath, publicFilesPath, webcomponentBundlePath } from './utils/path-utils.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 { 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'; import cookieParser from 'cookie-parser';
const createApp = () => { 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}/rooms`, /*mediaTypeValidatorMiddleware,*/ roomRouter);
app.use(`${MEET_API_BASE_PATH_V1}/recordings`, /*mediaTypeValidatorMiddleware,*/ recordingRouter); 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}/auth`, /*mediaTypeValidatorMiddleware,*/ authRouter);
app.use(`${MEET_API_BASE_PATH_V1}/participants`, participantsRouter);
// TODO: This route should be part of the rooms router // TODO: This route should be part of the rooms router
app.use(`${MEET_API_BASE_PATH_V1}/preferences`, /*mediaTypeValidatorMiddleware,*/ preferencesRouter); app.use(`${MEET_API_BASE_PATH_V1}/preferences`, /*mediaTypeValidatorMiddleware,*/ preferencesRouter);
// Internal routes // 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('/meet/health', (_req: Request, res: Response) => res.status(200).send('OK'));
app.use('/livekit/webhook', livekitRouter); app.use('/livekit/webhook', livekitRouter);