<commit_before>'use strict';

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

function errText(text) { throw new Error(text); }
function errTexter(text) { return function (hook) { errText(text); } }

exports.before = {
  all: [
  ],
  find: [
	errTexter("Finding uploads is not a thing.")
  ],
  get: [],
  create: [
    function (hook) {
	if ('provider' in hook.params && hook.params['provider'] != '') {
		return Promise.reject(new Error("No direct uploads."));
    	} else if (!hook.data.uri && hook.params.file) {
    		const file = hook.params.file;
    		const uri = dauria.getBase64DataURI(file.buffer, file.mimetype);
    		hook.data = {uri: uri};
    	}
    }
  ],
  update: [
	errTexter("Updating records is not a thing.")
  ],
  patch: [
	errTexter("Patching records is not a thing.")
  ],
  remove: [
	errTexter("Removing records is not a thing.")
  ]
};

exports.after = {
  all: [],
  find: [],
  get: [],
  create: [],
  update: [],
  patch: [],
  remove: []
};<commit_msg>Fix the upload hook.<commit_after>'use strict';

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

function errText(text) { throw new Error(text); }
function errTexter(text) { return function (hook) { errText(text); } }

exports.before = {
  all: [
  ],
  find: [
	errTexter("Finding uploads is not a thing.")
  ],
  get: [],
  create: [
    function (hook) {
	if ('provider' in hook.params && hook.params['provider'] != '') {
		return Promise.reject(new Error("No direct uploads."));
    	} else if (!hook.data.uri && hook.params.file) {
    		const file = hook.params.file;
    		const uri = dauria.getBase64DataURI(file.buffer, file.mimetype);
    		hook.data = {uri: uri};
    	}
	return Promise.resolve(hook);
    }
  ],
  update: [
	errTexter("Updating records is not a thing.")
  ],
  patch: [
	errTexter("Patching records is not a thing.")
  ],
  remove: [
	errTexter("Removing records is not a thing.")
  ]
};

exports.after = {
  all: [],
  find: [],
  get: [],
  create: [],
  update: [],
  patch: [],
  remove: []
};
{'fraction_non_alphanumeric': 0.18177697189483227, 'fraction_numerical': 0.001813236627379873, 'mean_word_length': 3.2688588007736943, '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': '5812436', 'n_tokens_mistral': 763, 'n_tokens_neox': 764, 'n_words': 181}