RealDevSquad / RealDevSquad/website-backend
Pattern refactor
Open
@Khanjan04 is already working on this.
Since Jan 17, 2021.
good first issue
refactor
- Dominant language
- JavaScript
- Stars
- 74
- Forks
- 276
- Avg merge
- 1d 26m
- Merged PRs (30d)
- 14
Description
Now:
const addNewTask = async (req, res) => {
try {
// LOGIC HERE
} catch (err) {
logger.error(`Error while fetching tasks ${err}`)
return res.boom.serverUnavailable('Something went wrong please contact admin')
}
}
}
const fetchTasks = async (req, res) => {
try {
// LOGIC HERE
} catch (err) {
logger.error(`Error while fetching tasks ${err}`)
return res.boom.serverUnavailable('Something went wrong please contact admin')
}
}
module.exports = {
addNewTask,
fetchTasks
}
Refactor:
// runtimeErrorHandler.js
const _addNewTask = async (req, res) => {
// LOGIC HERE
}
const addNewTask = runtimeErrorHandler(_addNewTask, [optional 'custom error message]');
module.exports = {
addNewTask,
fetchTasks
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.