Last active
January 12, 2020 06:57
-
-
Save anshuman-singh-93/a644bc12f7d8f88848f3f139391bd0bd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // user.controller.js | |
| const { UserError } = require('./util') | |
| const saveUser = async ({ body } = {}) => { | |
| if (!body.name) { | |
| throw new UserError('name field is missing',400); // operational error | |
| } | |
| let result1 = await saveUserInDB(body); | |
| let result2 = await sendToOtherService(result1); | |
| return result1; | |
| }; | |
| module.exports = { saveUser } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment