feathersjs-ecosystem/feathers-mailer

find hook for mailer service is missing

MarcGodard opened this issue · 1 comments

To reproduce:

  • Install feathers
  • generate app
  • upgrade to dove
  • install this mailer package
  • user this package as a service like below:
// Initializes the `mailer` service on path `/mailer`
const hooks = require('./mailer.hooks')
const mailer = require('feathers-mailer')

module.exports = function (app) {
  const transporter = app.get('mailer')
  if (transporter.dkim.domainName === 'SITE_DOMAIN') delete transporter.dkim

  // Initialize our service with any options it requires
  app.use('/api/mailer', mailer(transporter, { from: transporter.auth.user }))

  // Get our initialized service so that we can register hooks
  const service = app.service('api/mailer')

  service.hooks(hooks)
}

Causes the following error with 5.0.0-pre.15 and up:

[nodemon] starting `node server/ --trace-warnings --abort-on-uncaught-exception`
/home/marcgodard/Documents/Github/template/node_modules/@feathersjs/feathers/lib/hooks/regular.js:122
                throw new Error(`'${method}' is not a valid hook method`);
                ^

Error: 'find' is not a valid hook method
    at /home/marcgodard/Documents/Github/template/node_modules/@feathersjs/feathers/lib/hooks/regular.js:122:23
    at Array.forEach (<anonymous>)
    at /home/marcgodard/Documents/Github/template/node_modules/@feathersjs/feathers/lib/hooks/regular.js:120:27
    at Array.forEach (<anonymous>)
    at createMap (/home/marcgodard/Documents/Github/template/node_modules/@feathersjs/feathers/lib/hooks/regular.js:115:24)
    at Service.regularHooks (/home/marcgodard/Documents/Github/template/node_modules/@feathersjs/feathers/lib/hooks/regular.js:163:21)
    at Service.service.hooks (/home/marcgodard/Documents/Github/template/node_modules/@feathersjs/feathers/lib/hooks/index.js:79:39)
    at Function.module.exports (/home/marcgodard/Documents/Github/template/server/services/mailer/mailer.service.js:27:11)
    at Function.configure (/home/marcgodard/Documents/Github/template/node_modules/@feathersjs/feathers/lib/application.js:43:18)
    at Function.module.exports (/home/marcgodard/Documents/Github/template/server/services/index.js:109:7)
    at Function.configure (/home/marcgodard/Documents/Github/template/node_modules/@feathersjs/feathers/lib/application.js:43:18)
    at Object.<anonymous> (/home/marcgodard/Documents/Github/template/server/app.js:81:5)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
[nodemon] app crashed - waiting for file changes before starting...
daffl commented

Thank you for putting up the pull request. This was really a regression in v5 and should be back to the old behaviour with feathersjs/feathers#2636