mysamai/mysam-core

View on GitHub
lib/hooks/add-tokenization.js

Summary

Maintainability
A
0 mins
Test Coverage
const debug = require('debug')('mysam-core/hooks/add-tokenization');

module.exports = function addTokenization () {
  return function (hook) {
    const text = hook.result.text || hook.result.action.text;

    return hook.app.service('tokenize').create({ text })
      .then(tokenized => {
        debug('Adding tokenization', tokenized);

        hook.result = Object.assign({}, tokenized, hook.result);
        return hook;
      });
  };
};