Last active
          June 29, 2019 13:22 
        
      - 
      
- 
        Save aleksandar-b/a929d52466dc0a840de4a9b69dbff0ae 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
    
  
  
    
  | import { should, each, iff, prop, props } from 'rvl-pipe' | |
| import { createUser, createAuthToken, authTokenValidator, requestValidator } from '../account' | |
| import ctx from './dummyContext' | |
| const registerUser = each( | |
| validateRequest(requestValidator), | |
| generatePasswordHash(prop('body.password'), 'passwordHash'), | |
| createDocument('users', createUser, "userAccount"), | |
| should(prop('userAccount'), 'invalidUser'), | |
| createJsonWebToken(createAuthToken), | |
| props({ token: prop('token') }), | |
| validateResponse(authTokenValidator) | |
| ); | |
| const registerHandler = (req, res) => regiterUser({ ...ctx, body: req.body, headers: req.headers }); | |
| app.post('api/v1/register', registerHandler); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment