backend: enhance API response messages
This commit is contained in:
parent
817acc8486
commit
01ffd49803
@ -45,7 +45,7 @@ export const login = async (req: Request, res: Response) => {
|
||||
)
|
||||
);
|
||||
logger.info(`Login succeeded for user '${username}'`);
|
||||
return res.status(200).json({ message: 'Login succeeded' });
|
||||
return res.status(200).json({ message: `User '${username}' logged in successfully` });
|
||||
} catch (error) {
|
||||
handleError(res, error, 'generating token');
|
||||
}
|
||||
@ -98,8 +98,8 @@ export const refreshToken = async (req: Request, res: Response) => {
|
||||
accessToken,
|
||||
getCookieOptions('/', INTERNAL_CONFIG.ACCESS_TOKEN_EXPIRATION)
|
||||
);
|
||||
logger.info(`Token refreshed for user ${username}`);
|
||||
return res.status(200).json({ message: 'Token refreshed' });
|
||||
logger.info(`Access token refreshed for user '${username}'`);
|
||||
return res.status(200).json({ message: `Access token for user '${username}' successfully refreshed` });
|
||||
} catch (error) {
|
||||
handleError(res, error, 'refreshing token');
|
||||
}
|
||||
@ -141,7 +141,7 @@ export const deleteApiKeys = async (_req: Request, res: Response) => {
|
||||
|
||||
try {
|
||||
await authService.deleteApiKeys();
|
||||
return res.status(204).send();
|
||||
return res.status(200).json({ message: 'API keys deleted successfully' });
|
||||
} catch (error) {
|
||||
handleError(res, error, 'deleting API keys');
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ export const endMeeting = async (req: Request, res: Response) => {
|
||||
logger.info(`Ending meeting from room '${roomId}'`);
|
||||
// To end a meeting, we need to delete the room from LiveKit
|
||||
await livekitService.deleteRoom(roomId);
|
||||
res.status(200).json({ message: 'Meeting ended successfully' });
|
||||
res.status(200).json({ message: `Meeting in room '${roomId}' ended successfully` });
|
||||
} catch (error) {
|
||||
handleError(res, error, `ending meeting from room '${roomId}'`);
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ export const updateParticipantRole = async (req: Request, res: Response) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const deleteParticipant = async (req: Request, res: Response) => {
|
||||
export const kickParticipant = async (req: Request, res: Response) => {
|
||||
const logger = container.get(LoggerService);
|
||||
const roomService = container.get(RoomService);
|
||||
const participantService = container.get(ParticipantService);
|
||||
@ -121,10 +121,12 @@ export const deleteParticipant = async (req: Request, res: Response) => {
|
||||
}
|
||||
|
||||
try {
|
||||
logger.verbose(`Deleting participant '${participantIdentity}' from room '${roomId}'`);
|
||||
await participantService.deleteParticipant(roomId, participantIdentity);
|
||||
res.status(200).json({ message: 'Participant deleted' });
|
||||
logger.verbose(`Kicking participant '${participantIdentity}' from room '${roomId}'`);
|
||||
await participantService.kickParticipant(roomId, participantIdentity);
|
||||
res.status(200).json({
|
||||
message: `Participant '${participantIdentity}' kicked successfully from room '${roomId}'`
|
||||
});
|
||||
} catch (error) {
|
||||
handleError(res, error, `deleting participant '${participantIdentity}' from room '${roomId}'`);
|
||||
handleError(res, error, `kicking participant '${participantIdentity}' from room '${roomId}'`);
|
||||
}
|
||||
};
|
||||
|
||||
@ -142,7 +142,7 @@ export const deleteRecording = async (req: Request, res: Response) => {
|
||||
|
||||
try {
|
||||
await recordingService.deleteRecording(recordingId);
|
||||
return res.status(204).send();
|
||||
return res.status(200).json({ message: `Recording '${recordingId}' deleted successfully` });
|
||||
} catch (error) {
|
||||
handleError(res, error, `deleting recording '${recordingId}'`);
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ export const changePassword = async (req: Request, res: Response) => {
|
||||
try {
|
||||
const userService = container.get(UserService);
|
||||
await userService.changePassword(user.username, currentPassword, newPassword);
|
||||
return res.status(200).json({ message: 'Password changed successfully' });
|
||||
return res.status(200).json({ message: `Password for user '${user.username}' changed successfully` });
|
||||
} catch (error) {
|
||||
handleError(res, error, 'changing password');
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ internalMeetingRouter.delete(
|
||||
withAuth(participantTokenValidator),
|
||||
withValidRoomId,
|
||||
withModeratorPermissions,
|
||||
participantCtrl.deleteParticipant
|
||||
participantCtrl.kickParticipant
|
||||
);
|
||||
internalMeetingRouter.put(
|
||||
'/:roomId/participants/:participantIdentity/role',
|
||||
|
||||
@ -129,9 +129,8 @@ export class ParticipantService {
|
||||
return this.livekitService.participantExists(roomId, participantNameOrIdentity, participantField);
|
||||
}
|
||||
|
||||
async deleteParticipant(roomId: string, participantIdentity: string): Promise<void> {
|
||||
this.logger.verbose(`Deleting participant '${participantIdentity}' from room '${roomId}'`);
|
||||
|
||||
async kickParticipant(roomId: string, participantIdentity: string): Promise<void> {
|
||||
this.logger.verbose(`Kicking participant '${participantIdentity}' from room '${roomId}'`);
|
||||
return this.livekitService.deleteParticipant(roomId, participantIdentity);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user