AI-Tennis-Coach/server/helper/makeResponse/index.js
2025-02-11 11:23:59 +05:30

52 lines
1.5 KiB
JavaScript
Executable file

export const responseMessages = {
USER_CREATED: "Users created successfully!",
USER_ALREADY_EXISTS: "Email is already in use",
USERNAME_ALREADY_EXISTS: "Username is already in use",
INVALID_CREDENTIALS: "Invalid Password",
USER_NOT_FOUND: "User doesn't exists",
UNAUTHORIZED: "Unauthorized",
SOMETHING_WRONG: "Something went wrong",
LOGIN_SUCCESS: "Login successfully",
USER_UPDATED: "User profile updated successfully",
QUESTIONS_CREATED: "Questions created successfully!",
QUESTIONS_UPDATED: "Question updated successfully",
QUESTIONS_NOT_FOUND: 'Question not found',
QUESTIONS_FETCHED: "Questions Fetched Successfully",
DATA_ADDED: "Data added successfully",
DATA_FETCHED: "Data fetched successfully",
INVALID_PARAMETERS: "Parameters are missing",
SHOT_FAILURE: "You haven't played this shot"
}
export const notificationPayload = {}
export const statusCodes = {
'SUCCESS': 200,
'RECORD_CREATED': 201,
'BAD_REQUEST': 400,
'AUTH_ERROR': 401,
'FORBIDDEN': 403,
'NOT_FOUND': 404,
'INVALID_REQUEST': 405,
'RECORD_ALREADY_EXISTS': 409,
'SERVER_ERROR': 500,
'UNAUTHORIZED': 400
}
const makeResponse = async (res, statusCode, success, message, payload = null, meta = {}) =>
new Promise(resolve => {
res.status(statusCode)
.send({
success,
code: statusCode,
message,
data: payload,
meta
});
resolve(statusCode);
});
export { makeResponse };