-
-
Save robotlolita/7396b1e4f59c37855761 to your computer and use it in GitHub Desktop.
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
function parse(body) { | |
return body.phoneNumber? validate(formatCountry(body.phoneNumber)).map(aggregate({ source: 'website' })) | |
: body.From? validate(formatCountry(body.From)).map(aggregate({ source: 'cookie' })) | |
: /* otherwise */ Failure({ status: 522, message: 'Please enter a valid US number!' }) | |
} | |
// This returns a promise with the result | |
export function create(req) { | |
return parse(req.body) | |
.toPromise() | |
.then(function({ number, source }) { | |
return { data: Pre.findOrCreate({phoneNumber, source}) }; | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment