{"size": 724, "ext": "js", "max_stars_repo_path": "api/okta/oktaRouter.js", "max_stars_repo_name": "ChristopherHarwell/story-squad-be-e", "max_stars_repo_stars_event_min_datetime": "2020-10-27T16:45:07.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-04T19:14:46.000Z", "max_issues_repo_path": "api/okta/oktaRouter.js", "max_issues_repo_name": "ChristopherHarwell/story-squad-be-e", "max_issues_repo_issues_event_min_datetime": "2020-11-05T18:36:27.000Z", "max_issues_repo_issues_event_max_datetime": "2021-02-26T21:59:34.000Z", "max_forks_repo_path": "api/okta/oktaRouter.js", "max_forks_repo_name": "ChristopherHarwell/story-squad-be-e", "max_forks_repo_forks_event_min_datetime": "2020-10-28T19:49:43.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-04T22:41:53.000Z"}
{"max_stars_count": 2, "max_issues_count": 10, "max_forks_count": 15, "avg_line_length": 23.3548387097, "max_line_length": 60, "alphanum_fraction": 0.5635359116}
const router = require('express').Router();
const oktaClient = require('../../lib/oktaClient');

/* Create a new User (register). */
router.post('/', async (req, res) => {
  if (!req.body) {
    return res.status(400).json({ error: 'NoCredentials' });
  }
  try {
    const newUser = {
      profile: {
        firstName: req.body.firstName,
        lastName: req.body.lastName,
        email: req.body.email,
        login: req.body.email,
      },
      credentials: {
        password: {
          value: req.body.password,
        },
      },
    };
    const data = await oktaClient.createUser(newUser);
    res.status(200).json(data);
  } catch (err) {
    res.status(400).json(err);
  }
});

module.exports = router;
