@rxdi/hapi 0.7.236 → 0.7.237
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.
|
@@ -3,6 +3,12 @@ import { PluginNameVersion, PluginBase, PluginPackage, ServerOptions, ServerRout
|
|
|
3
3
|
export declare class HapiConfigModel {
|
|
4
4
|
randomPort?: boolean;
|
|
5
5
|
staticConfig?: ServerRoute | ServerRoute[];
|
|
6
|
+
/**
|
|
7
|
+
* This parameter let use choose between running a hapi server
|
|
8
|
+
* on a port aka stanadalone server or only bootstraping routes
|
|
9
|
+
* and running it as a lambda by using `server.inject({...requestParams})`
|
|
10
|
+
* */
|
|
11
|
+
mode?: 'lambda' | 'server';
|
|
6
12
|
hapi?: ServerOptions;
|
|
7
13
|
plugins?: Array<PluginBase<any, any> & (PluginNameVersion | PluginPackage)>;
|
|
8
14
|
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { BootstrapLogger, ExitHandlerService } from "@rxdi/core";
|
|
2
|
+
import { HapiConfigModel } from "../../hapi.module.config";
|
|
2
3
|
import { Server, PluginBase, PluginNameVersion, PluginPackage } from "@hapi/hapi";
|
|
3
4
|
export type PluginType<T> = (PluginBase<T, any> & (PluginNameVersion | PluginPackage))[];
|
|
4
5
|
export declare class ServerService {
|
|
5
6
|
private server;
|
|
6
7
|
private plugins;
|
|
8
|
+
private config;
|
|
7
9
|
private logger;
|
|
8
10
|
private exitHandler;
|
|
9
|
-
constructor(server: Server, plugins: PluginType<any>, logger: BootstrapLogger, exitHandler: ExitHandlerService);
|
|
11
|
+
constructor(server: Server, plugins: PluginType<any>, config: HapiConfigModel, logger: BootstrapLogger, exitHandler: ExitHandlerService);
|
|
10
12
|
start(): Promise<void>;
|
|
11
13
|
registerPlugins<T>(plugins: PluginType<T>): Promise<any[]>;
|
|
12
14
|
}
|
|
@@ -26,9 +26,10 @@ const core_1 = require("@rxdi/core");
|
|
|
26
26
|
const hapi_module_config_1 = require("../../hapi.module.config");
|
|
27
27
|
const hapi_1 = require("@hapi/hapi");
|
|
28
28
|
let ServerService = class ServerService {
|
|
29
|
-
constructor(server, plugins, logger, exitHandler) {
|
|
29
|
+
constructor(server, plugins, config, logger, exitHandler) {
|
|
30
30
|
this.server = server;
|
|
31
31
|
this.plugins = plugins;
|
|
32
|
+
this.config = config;
|
|
32
33
|
this.logger = logger;
|
|
33
34
|
this.exitHandler = exitHandler;
|
|
34
35
|
this.exitHandler.errorHandler.subscribe(() => __awaiter(this, void 0, void 0, function* () { return yield this.server.stop(); }));
|
|
@@ -39,15 +40,20 @@ let ServerService = class ServerService {
|
|
|
39
40
|
yield this.registerPlugins(this.plugins);
|
|
40
41
|
}
|
|
41
42
|
try {
|
|
42
|
-
|
|
43
|
+
if (this.config.mode === 'lambda') {
|
|
44
|
+
yield this.server.initialize();
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
yield this.server.start();
|
|
48
|
+
this.logger.log(`
|
|
49
|
+
Server running at: http://${this.server.info.address}:${this.server.info.port},
|
|
50
|
+
Environment: ${process.env.NODE_ENV || 'development'}
|
|
51
|
+
`);
|
|
52
|
+
}
|
|
43
53
|
}
|
|
44
54
|
catch (err) {
|
|
45
55
|
throw new Error(err);
|
|
46
56
|
}
|
|
47
|
-
this.logger.log(`
|
|
48
|
-
Server running at: http://${this.server.info.address}:${this.server.info.port},
|
|
49
|
-
Environment: ${process.env.NODE_ENV || 'development'}
|
|
50
|
-
`);
|
|
51
57
|
});
|
|
52
58
|
}
|
|
53
59
|
registerPlugins(plugins) {
|
|
@@ -61,6 +67,8 @@ exports.ServerService = ServerService = __decorate([
|
|
|
61
67
|
(0, core_1.Service)(),
|
|
62
68
|
__param(0, (0, core_1.Inject)(hapi_module_config_1.HAPI_SERVER)),
|
|
63
69
|
__param(1, (0, core_1.Inject)(hapi_module_config_1.HAPI_PLUGINS)),
|
|
64
|
-
|
|
70
|
+
__param(2, (0, core_1.Inject)(hapi_module_config_1.HAPI_CONFIG)),
|
|
71
|
+
__metadata("design:paramtypes", [hapi_1.Server, Array, hapi_module_config_1.HapiConfigModel,
|
|
72
|
+
core_1.BootstrapLogger,
|
|
65
73
|
core_1.ExitHandlerService])
|
|
66
74
|
], ServerService);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rxdi/hapi",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.237",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/rxdi/hapi"
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@hapi/inert": "^7.1.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@rxdi/core": "^0.7.
|
|
35
|
+
"@rxdi/core": "^0.7.236",
|
|
36
36
|
"@types/node": "^25.0.3",
|
|
37
37
|
"typescript": "^5.9.3"
|
|
38
38
|
}
|