fix(send-email-server): use config package according to documentation
config is a node package and not a directory path: https://www.npmjs.com/package/config
The documented way to use it is config.get('key.path');
. It seems to work with config.key.path
because there's a default.js
file in there, but I guess this is an implementation specific thing and it might change. Also, if we move mailer config to other file, like local.js
this won't work anymore. Another thing worth mentioning is that the errors are harder to read when you use config.key.path
:
AssertionError [ERR_ASSERTION]: missing path
at Module.require (module.js:594:3)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/mihail/root/proj/yld/repos/xpub-elife/node_modules/@pubsweet/component-send-email/src/SendEmail.js:7:18)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
vs this with config.get()
Error: Configuration property "mailer.path" is not defined
at Config.get (/home/mihail/root/proj/yld/repos/xpub-elife/node_modules/config/lib/config.js:202:11)
at Object.<anonymous> (/home/mihail/root/proj/yld/repos/xpub-elife/node_modules/@pubsweet/component-send-email/src/SendEmail.js:7:33)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/mihail/root/proj/yld/repos/xpub-elife/node_modules/@pubsweet/component-send-email/index.js:1:80)