Skip to content

Instantly share code, notes, and snippets.

@anshuman-singh-93
Last active January 12, 2020 06:57
Show Gist options
  • Save anshuman-singh-93/a644bc12f7d8f88848f3f139391bd0bd to your computer and use it in GitHub Desktop.
Save anshuman-singh-93/a644bc12f7d8f88848f3f139391bd0bd to your computer and use it in GitHub Desktop.
// 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