text: const { associateCurrentUser, queryWithCurrentUser } = require('feathers-authentication-hooks');
  const { hooks } = require('mostly-feathers-mongoose');
  const { cache } = require('mostly-feathers-cache');
  const contents = require('playing-content-common');
  const { BookEntity } = require('playing-book-common');
  
  module.exports = function (options = {}) {
    return {
      before: {
        all: [
          hooks.authenticate('jwt', options.auth),
          cache(options.cache, { headers: ['enrichers-document'] })
        ],
        get: [
          // queryWithCurrentUser({ idField: 'id', as: 'creator' })
        ],
        find: [
          // queryWithCurrentUser({ idField: 'id', as: 'creator' })
        ],
        create: [
          associateCurrentUser({ idField: 'id', as: 'creator' }),
          contents.computePath({ type: 'book' }),
          contents.computeAncestors()
        ],
        update: [
          associateCurrentUser({ idField: 'id', as: 'creator' }),
          hooks.depopulate('parent'),
          hooks.discardFields('metadata', 'ancestors', 'createdAt', 'updatedAt', 'destroyedAt'),
          contents.computePath({ type: 'book' }),
          contents.computeAncestors()
        ],
        patch: [
          associateCurrentUser({ idField: 'id', as: 'creator' }),
          hooks.depopulate('parent'),
          hooks.discardFields('metadata', 'ancestors', 'createdAt', 'updatedAt', 'destroyedAt'),
          contents.computePath({ type: 'book' }),
          contents.computeAncestors()
        ]
      },
      after: {
        all: [
          hooks.populate('parent', { service: 'folders', fallThrough: ['headers'] }),
          hooks.populate('ancestors'), // with typed id
          hooks.populate('creator', { service: 'users' }),
          contents.documentEnrichers(options),
          cache(options.cache, { headers: ['enrichers-document'] }),
          hooks.presentEntity(BookEntity, options.entities),
          hooks.responder()
        ],
        create: [
          contents.documentNotifier('document.create')
        ]
      }
    };
  };