-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adapt plugin to hapi v17 #16
Conversation
Codecov Report
@@ Coverage Diff @@
## master #16 +/- ##
==========================================
- Coverage 86.6% 82.38% -4.22%
==========================================
Files 9 11 +2
Lines 321 352 +31
Branches 41 47 +6
==========================================
+ Hits 278 290 +12
- Misses 43 62 +19
Continue to review full report at Codecov.
|
@@ -158,19 +161,26 @@ exports.SEVERITY_CODE = SEVERITY_CODE; | |||
exports.SEVERITY_NAME = SEVERITY_NAME; | |||
|
|||
// Hapi.js plugin registration | |||
exports.register = (server, options, next) => { | |||
exports.register = async (server, options, next) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async
без await
'ов.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
И, кстати, как hapi < 17 отреагирует на то, что register
вернёт промис?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hapi < 17 нормально это воспринимает. А для 17+ это может быть критично, он await-ит регистрацию плагина.
src/index.js
Outdated
// Hapi plugin metadata | ||
exports.register.attributes = { | ||
pkg: require('../package.json') | ||
exports.plugin = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А может лучше назвать не plugin
, а hapi17
?
src/plugin/hapi-17.js
Outdated
* HapiPlugin | ||
* | ||
*/ | ||
export class HapiPlugin { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Этот класс можно сделать общим для обоих hapi. В hapi<17 просто event.error
всегда будет undefined
hapi v17 release notes: hapijs/hapi#3658