<commit_before>module.exports = app => {
  const Documents = app.domain.document.Documents;
  const sequelize = app.sequelize;

  app.route("/service/document")
  //.all(app.auth.authenticate())

  .get((req, res) => {
    Documents.findAll({order: 'code ASC'})
    .then(result => res.json(result))
    .catch(error => {
      res.status(412).json({msg: error.message});
    });
  })

  .post((req, res) => {
    Documents.create(req.body)
    .then(result => res.status(201).json(result))
    .catch(error => {
      res.status(412).json({msg: error.message});
    });
  });

  app.route("/service/document/search")
  .get((req, res) => {
    let where = {};

    if(req.query.projectId)
      where.projct_id = req.query.projectId;
    if(req.query.code)
      where.code = {like: '%' + req.query.code + '%'};
    if(req.query.name)
      where.name = {like: '%' + req.query.name + '%'};

    Documents.findAll({where, order: 'code ASC'})<commit_msg>add fix project in doc<commit_after>module.exports = app => {
  const Projects = app.domain.project.Projects;
  const Documents = app.domain.document.Documents;
  const sequelize = app.sequelize;

  app.route("/service/document")
  //.all(app.auth.authenticate())

  .get((req, res) => {
    Documents.findAll({order: 'code ASC'})
    .then(result => res.json(result))
    .catch(error => {
      res.status(412).json({msg: error.message});
    });
  })

  .post((req, res) => {
    Projects.findOne({where: {code: "AUDINT"}})
      .then(result => {
        req.body.project_id = result.id;

        Documents.create(req.body)
        .then(result => res.status(201).json(result))
        .catch(error => {
          res.status(412).json({msg: error.message});
        });

      })
      .catch(error => {
        res.status(500).json({msg: "Não existe nenhum projecto cadastrado com o código AUDINT"});
      });


  });

  app.route("/service/document/search")
  .get((req, res) => {
    let where = {};

    if(req.query.projectId)
      where.projct_id = req.query.projectId;
    if(req.query.code)
      where.code = {like: '%' + req.query.code + '%'};
    if(req.query.name)
      where.name = {like: '%' + req.query.name + '%'};

    Documents.findAll({where, order: 'code ASC'})
{'fraction_non_alphanumeric': 0.1999107541276216, 'fraction_numerical': 0.009370816599732263, 'mean_word_length': 2.761744966442953, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '7304610', 'n_tokens_mistral': 826, 'n_tokens_neox': 772, 'n_words': 119}