<commit_before>'use strict';

const hooks = require('feathers-hooks');
const auth = require('feathers-authentication').hooks;

const restrictToSender = require('./restrict-to-sender');
const process = require('./process');
const globalHooks = require('../../../hooks');

exports.before = {
  all: [
    auth.verifyToken(),
    auth.populateUser(),
    auth.restrictToAuthenticated()
  ],
  find: [],
  get: [],
  create: [process()],
  update: [hooks.remove('sentBy'), restrictToSender()],
  patch: [hooks.remove('sentBy'), restrictToSender()],
  remove: [restrictToSender()]
};

exports.after = {
  all: [], // Populate the sender
  find: [hooks.populate('sentBy', { service: 'users', field: 'userId' })],
  get: [hooks.populate('sentBy', { service: 'users',  field: 'userId' })],
  create: [hooks.populate('sentBy', { service: 'users', field: 'userId' })],
  update: [],
  patch: [],<commit_msg>Refactoring to follow the getting started guide.<commit_after>'use strict';

const hooks = require('feathers-hooks');
const auth = require('feathers-authentication').hooks;

const restrictToSender = require('./restrict-to-sender');
const process = require('./process');
const globalHooks = require('../../../hooks');
const populateSender = hooks.populate('sentBy', {
  service: 'users',
  field: 'userId'
});

exports.before = {
  all: [
    auth.verifyToken(),
    auth.populateUser(),
    auth.restrictToAuthenticated()
  ],
  find: [],
  get: [],
  create: [process()],
  update: [hooks.remove('sentBy'), restrictToSender()],
  patch: [hooks.remove('sentBy'), restrictToSender()],
  remove: [restrictToSender()]
};

exports.after = {
  all: [], // Populate the sender
  find: [populateSender],
  get: [populateSender],
  create: [populateSender],
  update: [],
  patch: [],
{'fraction_non_alphanumeric': 0.20022560631697686, 'fraction_numerical': 0.0, 'mean_word_length': 4.631746031746032, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4536268', 'n_tokens_mistral': 556, 'n_tokens_neox': 577, 'n_words': 119}