use response middleware in InviteController
This commit is contained in:
1 parent
0aaeeef113
commit
e5f8d88c5a
2 files changed
+15
-5
No files matched your search
@@ -7,7 +7,7 @@ import logger from "../utils/logger.js";
|
|||||||
import jwt from "jsonwebtoken";
|
import jwt from "jsonwebtoken";
|
||||||
import { handleError, handleValidationError } from "./controllerUtils.js";
|
import { handleError, handleValidationError } from "./controllerUtils.js";
|
||||||
import { getTokenFromHeaders } from "../utils/utils.js";
|
import { getTokenFromHeaders } from "../utils/utils.js";
|
||||||
|
import { successMessages } from "../utils/messages.js";
|
||||||
const SERVICE_NAME = "inviteController";
|
const SERVICE_NAME = "inviteController";
|
||||||
|
|
||||||
class InviteController {
|
class InviteController {
|
||||||
@@ -65,9 +65,10 @@ class InviteController {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return res
|
return res.success({
|
||||||
.status(200)
|
msg: successMessages.INVITE_ISSUED,
|
||||||
.json({ success: true, msg: "Invite sent", data: inviteToken });
|
data: inviteToken,
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
next(handleError(error, SERVICE_NAME, "inviteController"));
|
next(handleError(error, SERVICE_NAME, "inviteController"));
|
||||||
}
|
}
|
||||||
@@ -83,7 +84,11 @@ class InviteController {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const invite = await this.db.getInviteToken(req.body.token);
|
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) {
|
} catch (error) {
|
||||||
next(handleError(error, SERVICE_NAME, "inviteVerifyController"));
|
next(handleError(error, SERVICE_NAME, "inviteVerifyController"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ const successMessages = {
|
|||||||
ALERT_EDIT: "Alert edited successfully",
|
ALERT_EDIT: "Alert edited successfully",
|
||||||
ALERT_DELETE: "Alert deleted successfully",
|
ALERT_DELETE: "Alert deleted successfully",
|
||||||
|
|
||||||
|
// Auth Controller
|
||||||
AUTH_CREATE_USER: "User created successfully",
|
AUTH_CREATE_USER: "User created successfully",
|
||||||
AUTH_LOGIN_USER: "User logged in successfully",
|
AUTH_LOGIN_USER: "User logged in successfully",
|
||||||
AUTH_LOGOUT_USER: "User logged out successfully",
|
AUTH_LOGOUT_USER: "User logged out successfully",
|
||||||
@@ -85,6 +86,10 @@ const successMessages = {
|
|||||||
AUTH_TOKEN_REFRESHED: "Auth token is refreshed",
|
AUTH_TOKEN_REFRESHED: "Auth token is refreshed",
|
||||||
AUTH_GET_ALL_USERS: "Got all users successfully",
|
AUTH_GET_ALL_USERS: "Got all users successfully",
|
||||||
|
|
||||||
|
// Invite Controller
|
||||||
|
INVITE_ISSUED: "Invite sent successfully",
|
||||||
|
INVITE_VERIFIED: "Invite verified successfully",
|
||||||
|
|
||||||
// Check Controller
|
// Check Controller
|
||||||
CHECK_CREATE: "Check created successfully",
|
CHECK_CREATE: "Check created successfully",
|
||||||
CHECK_GET: "Got checks successfully",
|
CHECK_GET: "Got checks successfully",
|
||||||
|
|||||||
Reference in new issue
Block a user