'use strict';

const express = require('express');
const router = express.Router();

const boom = require('boom');
const bcrypt = require('bcrypt-as-promised');
const { camelizeKeys, decamelizeKeys } = require('humps');
// const ev = require('express-validation');
// const validations = require('../validations/topics');
const knex = require('../knex');

router.post('/api/users', (req, res, next) => {
  const { email, password } = req.body;

  knex('users')
    .select(knex.raw('1=1'))
    .where('email', email)
    .first()
    .then((exists) => {
      if (exists) {
        throw boom.badRequest('This email is already registered');
      }

      return bcrypt.hash(password, 12);
    })
    .then((hashedPassword) => {
      const { firstName, lastName, aboutMe, avatarId, phone } = req.body;
      const user = {firstName, lastName, email, aboutMe, avatarId, phone, hashedPassword };
      const row = decamelizeKeys(user);

      return knex('users').insert(row, '*');
    })
    .then((rows) => {
      const user = camelizeKeys(rows[0]);

      delete user.hashedPassword;

      res.send(user);
    })
    .catch((err) => {
      next(err);
    });
});

module.exports = router;

@@ -1162,16 +1162,330 @@
 );%0A%7D);%0A%0A
+router.get('/api/users/:userId', (req, res, next) =%3E %7B%0A  const userId = Number.parseInt(req.params.userId);%0A%0A  knex('users')%0A    .where('id', userId)%0A    .then((user) =%3E %7B%0A      if (!user) %7B%0A        return next();%0A      %7D%0A      res.send(user);%0A    %7D)%0A    .catch((err) =%3E %7B%0A      next(boom.wrap(err));%0A    %7D);%0A%7D);%0A%0A
 module.e

Add get request for users