<commit_before>import httpStatus from 'http-status';
import userService from '../services/user';

function getUser(req, res) {
  return res.json(req.user);
}

function createUser(req, res, next) {
  userService.createUser(req.body)
    .then(createdUser => res.json(createdUser))
    .catch(err => next(err));
}

function updateUser(req, res, next) {
  userService.updateUser(req.params.userId, req.body)
    .then(updatedUser => res.json(updatedUser))
    .catch(err => next(err));
}

function deleteUser(req, res, next) {
  userService.deleteUser(req.params.userId)
    .then(() => res.sendStatus(httpStatus.OK))
    .catch(err => next(err));
}

/**
 * Device modifications
 */

function getDevice(req, res, next) {
  userService.getDevice(req.user, req.params.deviceId)
    .then(device => res.json(device))
    .catch(err => next(err));
}

function addDevice(req, res, next) {
  userService.addDevice(req.user, req.body.device, req.body.index)
    .then(user => res.json(user))
    .catch(err => next(err));
}

function updateDevice(req, res, next) {
  userService.updateDevice(req.user, req.params.deviceId, req.body)
    .then(user => res.json(user))
    .catch(err => next(err));
}

function sortDevices(req, res, next) {
  userService.sortDevices(req.user, req.params.sortOrder)
    .then(user => res.json(user))
    .catch(err => next(err));
}

function removeDevice(req, res, next) {
  userService.removeDevice(req.user, req.params.deviceId)
    .then(() => res.sendStatus(httpStatus.OK))
    .catch(err => next(err));
}
<commit_msg>Return user from deleteDevice (#35)<commit_after>import httpStatus from 'http-status';
import userService from '../services/user';

function getUser(req, res) {
  return res.json(req.user);
}

function createUser(req, res, next) {
  userService.createUser(req.body)
    .then(createdUser => res.json(createdUser))
    .catch(err => next(err));
}

function updateUser(req, res, next) {
  userService.updateUser(req.params.userId, req.body)
    .then(updatedUser => res.json(updatedUser))
    .catch(err => next(err));
}

function deleteUser(req, res, next) {
  userService.deleteUser(req.params.userId)
    .then(() => res.sendStatus(httpStatus.OK))
    .catch(err => next(err));
}

/**
 * Device modifications
 */

function getDevice(req, res, next) {
  userService.getDevice(req.user, req.params.deviceId)
    .then(device => res.json(device))
    .catch(err => next(err));
}

function addDevice(req, res, next) {
  userService.addDevice(req.user, req.body.device, req.body.index)
    .then(user => res.json(user))
    .catch(err => next(err));
}

function updateDevice(req, res, next) {
  userService.updateDevice(req.user, req.params.deviceId, req.body)
    .then(user => res.json(user))
    .catch(err => next(err));
}

function sortDevices(req, res, next) {
  userService.sortDevices(req.user, req.params.sortOrder)
    .then(user => res.json(user))
    .catch(err => next(err));
}

function removeDevice(req, res, next) {
  userService.removeDevice(req.user, req.params.deviceId)
    .then(user => res.json(user))
    .catch(err => next(err));
}

{'fraction_non_alphanumeric': 0.17318255250403877, 'fraction_numerical': 0.0006462035541195477, 'mean_word_length': 4.247457627118644, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4980867', 'n_tokens_mistral': 1073, 'n_tokens_neox': 1073, 'n_words': 194}