Skip to content

Commit 0f8238d

Browse files
authored
Upgrade production deps for hapi v21 and node v18 (#4361)
* Upgrade production deps for hapi v21 and node v18 * Account for change to podium emit(), no longer can be awaited. Closes #4184
1 parent 554294e commit 0f8238d

File tree

9 files changed

+47
-41
lines changed

9 files changed

+47
-41
lines changed

API.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,11 +1539,11 @@ async function example() {
15391539
const server = Hapi.server({ port: 80 });
15401540
server.event('test');
15411541
server.events.on('test', (update) => console.log(update));
1542-
await server.events.emit('test', 'hello');
1542+
await server.events.gauge('test', 'hello');
15431543
}
15441544
```
15451545

1546-
### <a name="server.events.emit()" /> `await server.events.emit(criteria, data)`
1546+
### <a name="server.events.emit()" /> `server.events.emit(criteria, data)`
15471547

15481548
Emits a custom application event to all the subscribed listeners where:
15491549

@@ -1569,7 +1569,7 @@ async function example() {
15691569
const server = Hapi.server({ port: 80 });
15701570
server.event('test');
15711571
server.events.on('test', (update) => console.log(update));
1572-
await server.events.emit('test', 'hello'); // await is optional
1572+
server.events.emit('test', 'hello');
15731573
}
15741574
```
15751575

@@ -1633,7 +1633,7 @@ async function example() {
16331633
const server = Hapi.server({ port: 80 });
16341634
server.event('test');
16351635
server.events.on('test', (update) => console.log(update));
1636-
await server.events.emit('test', 'hello');
1636+
server.events.emit('test', 'hello');
16371637
}
16381638
```
16391639

@@ -1651,8 +1651,8 @@ async function example() {
16511651
const server = Hapi.server({ port: 80 });
16521652
server.event('test');
16531653
server.events.once('test', (update) => console.log(update));
1654-
await server.events.emit('test', 'hello');
1655-
await server.events.emit('test', 'hello'); // Ignored
1654+
server.events.emit('test', 'hello');
1655+
server.events.emit('test', 'hello'); // Ignored
16561656
}
16571657
```
16581658

@@ -1670,11 +1670,17 @@ async function example() {
16701670
const server = Hapi.server({ port: 80 });
16711671
server.event('test');
16721672
const pending = server.events.once('test');
1673-
await server.events.emit('test', 'hello');
1673+
server.events.emit('test', 'hello');
16741674
const update = await pending;
16751675
}
16761676
```
16771677

1678+
### <a name="server.events.gauge()" /> `await server.events.gauge(criteria, data)`
1679+
1680+
Behaves identically to [`server.events.emit()`](#server.events.emit()), but also returns an array of the results of all the event listeners that run. The return value is that of `Promise.allSettled()`, where each item in the resulting array is `{ status: 'fulfilled', value }` in the case of a successful handler, or `{ status: 'rejected', reason }` in the case of a handler that throws.
1681+
1682+
Please note that system errors such as a `TypeError` are not handled specially, and it's recommended to scrutinize any rejections using something like [bounce](https://hapi.dev/module/bounce/).
1683+
16781684
### <a name="server.expose()" /> `server.expose(key, value, [options])`
16791685

16801686
Used within a plugin to expose a property via [`server.plugins[name]`](#server.plugins) where:

lib/core.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ const Boom = require('@hapi/boom');
99
const Bounce = require('@hapi/bounce');
1010
const Call = require('@hapi/call');
1111
const Catbox = require('@hapi/catbox');
12-
const CatboxMemory = require('@hapi/catbox-memory');
13-
const Heavy = require('@hapi/heavy');
12+
const { Engine: CatboxMemory } = require('@hapi/catbox-memory');
13+
const { Heavy } = require('@hapi/heavy');
1414
const Hoek = require('@hapi/hoek');
1515
const { Mimos } = require('@hapi/mimos');
1616
const Podium = require('@hapi/podium');
@@ -58,7 +58,7 @@ exports = module.exports = internals.Core = class {
5858
compression = new Compression();
5959
controlled = null; // Other servers linked to the phases of this server
6060
dependencies = []; // Plugin dependencies
61-
events = new Podium(internals.events);
61+
events = new Podium.Podium(internals.events);
6262
heavy = null;
6363
info = null;
6464
instances = new Set();
@@ -293,7 +293,7 @@ exports = module.exports = internals.Core = class {
293293
}
294294

295295
this.phase = 'started';
296-
await this.events.emit('start');
296+
this.events.emit('start');
297297

298298
try {
299299
if (this.controlled) {
@@ -415,7 +415,7 @@ exports = module.exports = internals.Core = class {
415415
this.caches.forEach((cache) => caches.push(cache.client.stop()));
416416
await Promise.all(caches);
417417

418-
await this.events.emit('stop');
418+
this.events.emit('stop');
419419
this.heavy.stop();
420420

421421
if (this.controlled) {

lib/request.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ exports = module.exports = internals.Request = class {
9797
get events() {
9898

9999
if (!this._events) {
100-
this._events = new Podium(internals.events);
100+
this._events = new Podium.Podium(internals.events);
101101
}
102102

103103
return this._events;

lib/response.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ exports = module.exports = internals.Response = class {
117117
get events() {
118118

119119
if (!this._events) {
120-
this._events = new Podium(internals.events);
120+
this._events = new Podium.Podium(internals.events);
121121
}
122122

123123
return this._events;

package.json

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,33 @@
2323
]
2424
},
2525
"dependencies": {
26-
"@hapi/accept": "^5.0.1",
27-
"@hapi/ammo": "^5.0.1",
28-
"@hapi/boom": "^9.1.0",
29-
"@hapi/bounce": "^2.0.0",
30-
"@hapi/call": "^8.0.0",
31-
"@hapi/catbox": "^11.1.1",
32-
"@hapi/catbox-memory": "^5.0.0",
33-
"@hapi/heavy": "^7.0.1",
34-
"@hapi/hoek": "^9.0.4",
35-
"@hapi/mimos": "^6.0.0",
36-
"@hapi/podium": "^4.1.1",
37-
"@hapi/shot": "6.0.0-beta.1",
38-
"@hapi/somever": "^3.0.0",
39-
"@hapi/statehood": "^7.0.3",
40-
"@hapi/subtext": "^7.0.3",
41-
"@hapi/teamwork": "^5.1.0",
42-
"@hapi/topo": "^5.0.0",
43-
"@hapi/validate": "^1.1.1"
26+
"@hapi/accept": "^6.0.0",
27+
"@hapi/ammo": "^6.0.0",
28+
"@hapi/boom": "^10.0.0",
29+
"@hapi/bounce": "^3.0.0",
30+
"@hapi/call": "^9.0.0",
31+
"@hapi/catbox": "^12.0.0",
32+
"@hapi/catbox-memory": "^6.0.0",
33+
"@hapi/heavy": "^8.0.0",
34+
"@hapi/hoek": "^10.0.0",
35+
"@hapi/mimos": "^7.0.0",
36+
"@hapi/podium": "^5.0.0",
37+
"@hapi/shot": "^6.0.0",
38+
"@hapi/somever": "^4.0.0",
39+
"@hapi/statehood": "^8.0.0",
40+
"@hapi/subtext": "^8.0.0",
41+
"@hapi/teamwork": "^6.0.0",
42+
"@hapi/topo": "^6.0.0",
43+
"@hapi/validate": "^2.0.0"
4444
},
4545
"devDependencies": {
46-
"@hapi/code": "9.0.0-beta.0",
47-
"@hapi/eslint-plugin": "^5.0.0",
46+
"@hapi/code": "^9.0.0",
47+
"@hapi/eslint-plugin": "^6.0.0",
4848
"@hapi/inert": "^6.0.2",
4949
"@hapi/joi-legacy-test": "npm:@hapi/joi@^15.0.0",
50-
"@hapi/lab": "25.0.0-beta.0",
50+
"@hapi/lab": "^25.0.1",
5151
"@hapi/vision": "^6.0.1",
52-
"@hapi/wreck": "^17.0.0",
52+
"@hapi/wreck": "^18.0.0",
5353
"handlebars": "^4.7.4",
5454
"joi": "^17.0.0",
5555
"legacy-readable-stream": "npm:readable-stream@^1.0.34"

test/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const Stream = require('stream');
1212
const TLS = require('tls');
1313

1414
const Boom = require('@hapi/boom');
15-
const CatboxMemory = require('@hapi/catbox-memory');
15+
const { Engine: CatboxMemory } = require('@hapi/catbox-memory');
1616
const Code = require('@hapi/code');
1717
const Handlebars = require('handlebars');
1818
const Hapi = require('..');

test/headers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const Boom = require('@hapi/boom');
4-
const CatboxMemory = require('@hapi/catbox-memory');
4+
const { Engine: CatboxMemory } = require('@hapi/catbox-memory');
55
const Code = require('@hapi/code');
66
const Hapi = require('..');
77
const Inert = require('@hapi/inert');

test/methods.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const Catbox = require('@hapi/catbox');
4-
const CatboxMemory = require('@hapi/catbox-memory');
4+
const { Engine: CatboxMemory } = require('@hapi/catbox-memory');
55
const Code = require('@hapi/code');
66
const Hapi = require('..');
77
const Hoek = require('@hapi/hoek');

test/server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const Path = require('path');
44
const Zlib = require('zlib');
55

66
const Boom = require('@hapi/boom');
7-
const CatboxMemory = require('@hapi/catbox-memory');
7+
const { Engine: CatboxMemory } = require('@hapi/catbox-memory');
88
const Code = require('@hapi/code');
99
const Handlebars = require('handlebars');
1010
const Hapi = require('..');
@@ -858,7 +858,7 @@ describe('Server', () => {
858858

859859
server.events.emit('test', 1);
860860
server.events.emit({ name: 'test', channel: 'x' }, 2);
861-
await plugin.events.emit({ name: 'test', channel: 'y' }, 3);
861+
plugin.events.emit({ name: 'test', channel: 'y' }, 3);
862862

863863
expect(updates).to.equal([
864864
{ id: 'server', update: 1 },

0 commit comments

Comments
 (0)