|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const swaggerDefaultResponseMessages = [ |
| 4 | + { code: 200, message: 'OK' }, |
| 5 | + { code: 400, message: 'Bad Request' }, |
| 6 | + { code: 401, message: 'Unauthorized' }, |
| 7 | + { code: 404, message: 'Data Not Found' }, |
| 8 | + { code: 500, message: 'Internal Server Error' } |
| 9 | +]; |
| 10 | + |
| 11 | +const STATUS_MSG = { |
| 12 | + ERROR: { |
| 13 | + INVALID_USER_PASS: { |
| 14 | + statusCode: 401, |
| 15 | + type: 'INVALID_USER_PASS', |
| 16 | + customMessage: 'Invalid username or password' |
| 17 | + }, |
| 18 | + SOCIAL_LOGIN_FAILED: { |
| 19 | + statusCode: 401, |
| 20 | + type: 'SOCIAL_LOGIN_FAILED', |
| 21 | + customMessage: 'Login Failed! Please try again.' |
| 22 | + }, |
| 23 | + INCORRECT_PASSWORD: { |
| 24 | + statusCode: 401, |
| 25 | + customMessage: 'Incorrect Password', |
| 26 | + type: 'INCORRECT_PASSWORD' |
| 27 | + }, |
| 28 | + ACCESS_DENIED: { |
| 29 | + statusCode: 401, |
| 30 | + customMessage: 'You do not have permission for this API', |
| 31 | + type: 'ACCESS_DENIED' |
| 32 | + }, |
| 33 | + DUPLICATE: { |
| 34 | + statusCode: 400, |
| 35 | + customMessage: 'Duplicate Entry', |
| 36 | + type: 'DUPLICATE' |
| 37 | + }, |
| 38 | + DB_ERROR: { |
| 39 | + statusCode: 400, |
| 40 | + customMessage: 'DB Error', |
| 41 | + type: 'DB_ERROR' |
| 42 | + }, |
| 43 | + INVALID_ID: { |
| 44 | + statusCode: 400, |
| 45 | + customMessage: 'Invalid Id Provided : ', |
| 46 | + type: 'INVALID_ID' |
| 47 | + }, |
| 48 | + APP_ERROR: { |
| 49 | + statusCode: 400, |
| 50 | + customMessage: 'Application Error', |
| 51 | + type: 'APP_ERROR' |
| 52 | + }, |
| 53 | + IMP_ERROR: { |
| 54 | + statusCode: 500, |
| 55 | + customMessage: 'Implementation Error', |
| 56 | + type: 'IMP_ERROR' |
| 57 | + }, |
| 58 | + INVALID_TOKEN: { |
| 59 | + statusCode: 401, |
| 60 | + customMessage: 'Invalid token provided', |
| 61 | + type: 'INVALID_TOKEN' |
| 62 | + }, |
| 63 | + EMAIL_NOT_VERIFIED: { |
| 64 | + statusCode: 401, |
| 65 | + customMessage: 'Your Email address is not verified.', |
| 66 | + type: 'EMAIL_NOT_VERIFIED' |
| 67 | + }, |
| 68 | + EMAIL_NOT_EXIST: { |
| 69 | + statusCode: 400, |
| 70 | + customMessage: 'Email address does not exist.', |
| 71 | + type: 'EMAIL_NOT_EXIST' |
| 72 | + }, |
| 73 | + ROLE_NOT_EXIST: { |
| 74 | + statusCode: 400, |
| 75 | + customMessage: 'Role does not exist', |
| 76 | + type: 'ROLE_NOT_EXIST' |
| 77 | + }, |
| 78 | + TOKEN_NOT_VERIFIED: { |
| 79 | + statusCode: 400, |
| 80 | + customMessage: 'Token is not verified.', |
| 81 | + type: 'TOKEN_NOT_VERIFIED' |
| 82 | + }, |
| 83 | + PASSWORD_NOT_MATCHED: { |
| 84 | + statusCode: 400, |
| 85 | + customMessage: 'Password and Confirm Password are not same.', |
| 86 | + type: 'PASSWORD_NOT_MATCHED' |
| 87 | + }, |
| 88 | + OLD_AND_NEW_PASSWORD_SHOULD_NOT_SAME: { |
| 89 | + statusCode: 400, |
| 90 | + customMessage: 'Old Password and New Password should not same.', |
| 91 | + type: 'OLD_AND_NEW_PASSWORD_SHOULD_NOT_SAME' |
| 92 | + } |
| 93 | + }, |
| 94 | + SUCCESS: { |
| 95 | + CREATED: { |
| 96 | + statusCode: 201, |
| 97 | + customMessage: 'Created Successfully', |
| 98 | + type: 'CREATED' |
| 99 | + }, |
| 100 | + DEFAULT: { |
| 101 | + statusCode: 200, |
| 102 | + customMessage: 'Success', |
| 103 | + type: 'DEFAULT' |
| 104 | + }, |
| 105 | + UPDATED: { |
| 106 | + statusCode: 200, |
| 107 | + customMessage: 'Updated Successfully', |
| 108 | + type: 'UPDATED' |
| 109 | + }, |
| 110 | + LOGOUT: { |
| 111 | + statusCode: 200, |
| 112 | + customMessage: 'Logged Out Successfully', |
| 113 | + type: 'LOGOUT' |
| 114 | + }, |
| 115 | + DELETED: { |
| 116 | + statusCode: 200, |
| 117 | + customMessage: 'Deleted Successfully', |
| 118 | + type: 'DELETED' |
| 119 | + }, |
| 120 | + FORGOT_PASSWORD_MAIL_SENT: { |
| 121 | + statusCode: 200, |
| 122 | + customMessage: 'Forgot password request initiated, check your mail.', |
| 123 | + type: 'MAIL_SENT' |
| 124 | + }, |
| 125 | + PASSWORD_CHANGED: { |
| 126 | + statusCode: 200, |
| 127 | + customMessage: 'Password Updated Successfully.', |
| 128 | + type: 'PASSWORD_CHANGED' |
| 129 | + }, |
| 130 | + AUTHENTICATED: { |
| 131 | + statusCode: 200, |
| 132 | + customMessage: 'User is authenticated', |
| 133 | + type: 'AUTHENTICATED' |
| 134 | + } |
| 135 | + } |
| 136 | +}; |
| 137 | + |
| 138 | +const Constants = { |
| 139 | + SERVER, |
| 140 | + STATUS_MSG, |
| 141 | + swaggerDefaultResponseMessages, |
| 142 | + notificationMessages, |
| 143 | + hashingSecret, |
| 144 | + defaultDistanceForRestaurantSearch, |
| 145 | + userRoles, |
| 146 | + serverUser |
| 147 | +}; |
| 148 | + |
| 149 | +module.exports = Constants; |
0 commit comments