<commit_before>import * as wappuMood from '../core/wappu-mood-core';
import {createJsonRoute, throwStatus} from '../util/express';


const putMood = createJsonRoute(function(req, res) {

  if (!req.client.id) {
    throwStatus(403, `Only registered user may save moods`);
  }

  return wappuMood.createOrUpdateMood(req.client)
    .then(result => undefined)
    .catch(err => {
      throw err
    });
});

const getMood = createJsonRoute(function(req, res) {

  if (!req.client.id) {
    throwStatus(403, `Only registered user may have personal mood log`);
  }

  return wappuMood.getMood(req.client)
    .then(result => result)
    .catch(err => {
      throw err
    });<commit_msg>Restored erroneously removed query validation<commit_after>import * as wappuMood from '../core/wappu-mood-core';
import {createJsonRoute, throwStatus} from '../util/express';
import {assert} from '../validation';
import _ from 'lodash';


const putMood = createJsonRoute(function(req, res) {
  if (!req.client.id) throwStatus(403, `Only registered user may save moods`);

  let moodParams = assert(req.body, 'upsertMoodParams');
  let coreParams = _.merge(moodParams, {
    client: req.client,
  });

  return wappuMood.createOrUpdateMood(coreParams)
    .then(result => undefined)
    .catch(err => {
      throw err
    });
});

const getMood = createJsonRoute(function(req, res) {
  if (!req.client.id) throwStatus(403, `Client id required`);

  return wappuMood.getMood(req.client)
    .then(result => result)
    .catch(err => {
      throw err
    });
{'fraction_non_alphanumeric': 0.14332036316472113, 'fraction_numerical': 0.007782101167315175, 'mean_word_length': 3.7186544342507646, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '6690324', 'n_tokens_mistral': 525, 'n_tokens_neox': 508, 'n_words': 119}