Skip to content

Instantly share code, notes, and snippets.

@mosufy
Last active June 5, 2021 04:45
Show Gist options
  • Save mosufy/71ac9ac5208c6cac53f292ce60b52624 to your computer and use it in GitHub Desktop.
Save mosufy/71ac9ac5208c6cac53f292ce60b52624 to your computer and use it in GitHub Desktop.
try {
const user = {
username: 'JohnDoe',
gender: 'male',
}
validateUsernameFormat(user.username);
await checkUsernameExists(user.username);
const userId = await insertNewUser(user);
await sendMessage('User created', { userId, user });
return {
data: {
message: 'User created successfully!'
}
}
} catch (error) {
return {
error: {
message: error.message,
code: 'FAILED_CREATE_USER',
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment