<commit_before>import jwt from 'jsonwebtoken';
import bcrypt from 'bcrypt-nodejs';
import db from '../models';
import Helper from '../helper/Helper';


const secret = process.env.SECRET || 'samplesecret';

export default {

  getAllUsers(req, res) {
    db.User.findAll({})
      .then(users => res.status(200).json({
        message: 'Successfull',
        users
      }))
      .catch(error => res.status(400).json({
        error
      }));
  },

  getOneUser(req, res) {
    // console.log(req.params.id);
    db.User.findById(req.params.id)
      .then(user => res.status(200)
        .json({
          message: 'Successful',
          user
        }))
      .catch(error => res.status(400).json({
        error
      }));
  },

  getUserPagination(req, res) {
    db.User.findAll({
      limit: 10
    })
      .then(limit => res.status(200).json({
        message: 'Successfull',
        limit
      }))
      .catch(error => res.status(400).json({
        error
      }));
  },

  getUserDocuments(req, res) {
    db.User.findOne({
      where: {
        id: req.params.id
      },
      include: {
        model: db.Document
      }
    }).then(documents => res.status(200)
      .json({
        message: 'Successfull',
        documents
      })).catch((error) => {
        res.status(400)
        .send(error);
      });
  },<commit_msg>refactor(controllers/user.js):modify functions in file [#144369551]<commit_after>import jwt from 'jsonwebtoken';
import bcrypt from 'bcrypt-nodejs';
import db from '../models';
import Helper from '../helper/Helper';


const secret = process.env.SECRET || 'samplesecret';

export default {

  getAllUsers(req, res) {
    return db.User.findAll({})
      .then(users => res.status(200).send({
        message: 'Successfull',
        users
      }))
      .catch(error => res.status(400).send({
        error
      }));
  },

  getOneUser(req, res) {
    return db.User.findById(req.params.id)
      .then(user => res.status(200)
        .send({
          message: 'Successful',
          user
        }))
      .catch(error => res.status(400).json({
        error
      }));
  },

  getUserPagination(req, res) {
    return db.User.findAll({
      limit: 10
    })
      .then(limit => res.status(200).json({
        message: 'Successfull',
        limit
      }))
      .catch(error => res.status(400).json({
        error
      }));
  },

  getUserDocuments(req, res) {
    return db.User.findOne({
      where: {
        id: req.params.id
      },
      include: {
        model: db.Document
      }
    }).then(documents => res.status(200)
      .json({
        message: 'Successfull',
        documents
      })).catch((error) => {
        res.status(400)
        .send(error);
      });
  },
{'fraction_non_alphanumeric': 0.16624134159679183, 'fraction_numerical': 0.022238425082026978, 'mean_word_length': 1.944206008583691, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '633948', 'n_tokens_mistral': 939, 'n_tokens_neox': 884, 'n_words': 161}