@rxdi/hapi 0.7.244 → 0.7.245
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +46 -0
- package/package.json +2 -2
package/dist/main.js
CHANGED
|
@@ -31,6 +31,16 @@ const inert_plugin_1 = require("./plugins/inert/inert.plugin");
|
|
|
31
31
|
let HapiModule = HapiModule_1 = class HapiModule {
|
|
32
32
|
static forRoot(config) {
|
|
33
33
|
config = Object.assign({}, config || new hapi_module_config_1.HapiConfigModel());
|
|
34
|
+
// Idempotent path: if HAPI_SERVER is already in the container (e.g.
|
|
35
|
+
// Lambforge container pre-bootstrapped hapi, and now the user's
|
|
36
|
+
// AppModule re-calls CoreModule.forRoot which transitively calls
|
|
37
|
+
// HapiModule.forRoot), we don't recreate the server. We merge as much
|
|
38
|
+
// configuration as can be applied to a live hapi server, warn on the
|
|
39
|
+
// rest, and return a no-op ModuleWithServices.
|
|
40
|
+
if (core_1.Container.has(hapi_module_config_1.HAPI_SERVER)) {
|
|
41
|
+
mergeIntoLiveServer(config);
|
|
42
|
+
return { module: HapiModule_1, providers: [] };
|
|
43
|
+
}
|
|
34
44
|
config.randomPort && config.hapi.port ? config.hapi.port = null : null;
|
|
35
45
|
return {
|
|
36
46
|
module: HapiModule_1,
|
|
@@ -64,6 +74,42 @@ exports.HapiModule = HapiModule = HapiModule_1 = __decorate([
|
|
|
64
74
|
plugins: []
|
|
65
75
|
})
|
|
66
76
|
], HapiModule);
|
|
77
|
+
/**
|
|
78
|
+
* Merges a HapiConfigModel into an already-bootstrapped hapi server.
|
|
79
|
+
*
|
|
80
|
+
* Semantics:
|
|
81
|
+
* - `hapi.port`: ignored with a warning if it differs — the live server is
|
|
82
|
+
* bound, port changes would require a restart.
|
|
83
|
+
* - `hapi.routes.*`: merged into `server.settings.routes` so routes
|
|
84
|
+
* registered AFTER this call (e.g. user controllers, GraphqlService
|
|
85
|
+
* registering /graphql in the lambda flow) pick them up. Already
|
|
86
|
+
* registered routes keep their original settings.
|
|
87
|
+
* - `plugins`: appended to HAPI_PLUGINS so HapiPlugin's later registration
|
|
88
|
+
* pass picks them up. (No effect if HapiPlugin already finished init.)
|
|
89
|
+
* - HAPI_CONFIG is updated in-place so any later reader sees the new shape.
|
|
90
|
+
*/
|
|
91
|
+
function mergeIntoLiveServer(config) {
|
|
92
|
+
const liveServer = core_1.Container.get(hapi_module_config_1.HAPI_SERVER);
|
|
93
|
+
const liveConfig = core_1.Container.get(hapi_module_config_1.HAPI_CONFIG);
|
|
94
|
+
const requestedPort = config.hapi && config.hapi.port;
|
|
95
|
+
const livePort = liveServer.info && liveServer.info.port;
|
|
96
|
+
if (requestedPort !== undefined && requestedPort !== null && livePort !== undefined && String(requestedPort) !== String(livePort)) {
|
|
97
|
+
console.warn(`[HapiModule] Port ${requestedPort} requested but live server is on ${livePort}; ` +
|
|
98
|
+
`port is fixed at container start. Ignoring requested port.`);
|
|
99
|
+
}
|
|
100
|
+
if (config.hapi && config.hapi.routes) {
|
|
101
|
+
const liveRoutes = liveServer.settings.routes || {};
|
|
102
|
+
Object.assign(liveRoutes, config.hapi.routes);
|
|
103
|
+
liveServer.settings.routes = liveRoutes;
|
|
104
|
+
}
|
|
105
|
+
if (config.plugins && config.plugins.length) {
|
|
106
|
+
const livePlugins = core_1.Container.get(hapi_module_config_1.HAPI_PLUGINS);
|
|
107
|
+
livePlugins.push(...config.plugins);
|
|
108
|
+
}
|
|
109
|
+
if (liveConfig) {
|
|
110
|
+
Object.assign(liveConfig, config);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
67
113
|
__exportStar(require("./hapi.module.config"), exports);
|
|
68
114
|
__exportStar(require("./plugins/index"), exports);
|
|
69
115
|
__exportStar(require("./services/index"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rxdi/hapi",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.245",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/rxdi/hapi"
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@hapi/inert": "^7.1.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@rxdi/core": "^0.7.
|
|
36
|
+
"@rxdi/core": "^0.7.244",
|
|
37
37
|
"@types/node": "^25.0.3",
|
|
38
38
|
"typescript": "^5.9.3"
|
|
39
39
|
}
|