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