-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature #162171020]: refactor profile codebase
- Add helper function Response - Update ProfileController - run test, test passes, commit, push to Github
- Loading branch information
1 parent
07a7ac5
commit 12f77ac
Showing
6 changed files
with
216 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/** | ||
* @description - This class is all about server response | ||
* @returns {class} Response | ||
*/ | ||
class Response { | ||
/** | ||
* @description - success response | ||
* @param {object} res | ||
* @param {object} data | ||
* @returns {object} Success | ||
*/ | ||
static success(res, data) { | ||
return res.status(200).json(data); | ||
} | ||
|
||
/** | ||
* @description - Not found response | ||
* @param {object} res | ||
* @param {object} data | ||
* @returns {object} Not found | ||
*/ | ||
static notfound(res, data) { | ||
return res.status(404).json(data); | ||
} | ||
|
||
/** | ||
* @description - Internal server error response | ||
* @param {object} res | ||
* @param {object} data | ||
* @returns {object} Error | ||
*/ | ||
static internalServerError(res, data) { | ||
return res.status(500).json(data); | ||
} | ||
|
||
/** | ||
* @description - bad request | ||
* @param {object} res | ||
* @param {object} data | ||
* @returns {object} Error | ||
*/ | ||
static badrequest(res, data) { | ||
return res.status(400).json(data); | ||
} | ||
|
||
/** | ||
* @description - created response | ||
* @param {object} res | ||
* @param {object} data | ||
* @returns {object} Created | ||
*/ | ||
static created(res, data) { | ||
return res.status(201).json(data); | ||
} | ||
|
||
/** | ||
* @description - Unauthorized credentials | ||
* @param {object} res | ||
* @param {object} data | ||
* @returns {object} Unauthorized | ||
*/ | ||
static unauthorized(res, data) { | ||
return res.status(401).json(data); | ||
} | ||
|
||
/** | ||
* @description - forbidden credentials | ||
* @param {object} res | ||
* @param {object} data | ||
* @returns {object} forbidden | ||
*/ | ||
static forbidden(res, data) { | ||
return res.status(403).json(data); | ||
} | ||
} | ||
|
||
export default Response; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.