{"size": 525, "ext": "js", "max_stars_repo_path": "src/controllers/users.js", "max_stars_repo_name": "babetmihai/node-server", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/controllers/users.js", "max_issues_repo_name": "babetmihai/node-server", "max_issues_repo_issues_event_min_datetime": "2021-09-02T09:37:18.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-02T09:37:18.000Z", "max_forks_repo_path": "src/controllers/users.js", "max_forks_repo_name": "babetmihai/node-server", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 23.8636363636, "max_line_length": 72, "alphanum_fraction": 0.6380952381}
const userService = require('../services/users')
const { Router } = require('express')
const { promisePool } =  require('../db')

const router = Router()
router.post('/users', async (req, res, next) => {
  let conn
  try {
    const { email, password } = req.body
    conn = await promisePool.getConnection()
    const user = await userService.createUser({ email, password, conn })
    res.status(200).json(user)
  } catch (error) {
    next(error)
  } finally {
    if (conn) conn.release()
  }
})

module.exports = router

