use response middleware in InviteController

This commit is contained in:
Alex Holliday committed 2025-01-19 09:59:13 -08:00
1 parent 0aaeeef113
commit e5f8d88c5a
2 files changed
+15 -5

No files matched your search

+10 -5
View File
@@ -7,7 +7,7 @@ import logger from "../utils/logger.js";
import jwt from "jsonwebtoken";
import { handleError, handleValidationError } from "./controllerUtils.js";
import { getTokenFromHeaders } from "../utils/utils.js";
import { successMessages } from "../utils/messages.js";
const SERVICE_NAME = "inviteController";
class InviteController {
@@ -65,9 +65,10 @@ class InviteController {
});
});
return res
.status(200)
.json({ success: true, msg: "Invite sent", data: inviteToken });
return res.success({
msg: successMessages.INVITE_ISSUED,
data: inviteToken,
});
} catch (error) {
next(handleError(error, SERVICE_NAME, "inviteController"));
}
@@ -83,7 +84,11 @@ class InviteController {
try {
const invite = await this.db.getInviteToken(req.body.token);
res.status(200).json({ status: "success", msg: "Invite verified", data: invite });
return res.success({
msg: successMessages.INVITE_VERIFIED,
data: invite,
});
} catch (error) {
next(handleError(error, SERVICE_NAME, "inviteVerifyController"));
}
+5
View File
@@ -73,6 +73,7 @@ const successMessages = {
ALERT_EDIT: "Alert edited successfully",
ALERT_DELETE: "Alert deleted successfully",
// Auth Controller
AUTH_CREATE_USER: "User created successfully",
AUTH_LOGIN_USER: "User logged in successfully",
AUTH_LOGOUT_USER: "User logged out successfully",
@@ -85,6 +86,10 @@ const successMessages = {
AUTH_TOKEN_REFRESHED: "Auth token is refreshed",
AUTH_GET_ALL_USERS: "Got all users successfully",
// Invite Controller
INVITE_ISSUED: "Invite sent successfully",
INVITE_VERIFIED: "Invite verified successfully",
// Check Controller
CHECK_CREATE: "Check created successfully",
CHECK_GET: "Got checks successfully",