@adonisjs/core 5.8.9 → 6.0.0-0
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/README.md +6 -15
- package/build/commands/commands.json +1 -0
- package/build/commands/eject.d.ts +8 -0
- package/build/commands/eject.js +34 -0
- package/build/commands/{GenerateKey.d.ts → generate_key.d.ts} +3 -4
- package/build/commands/generate_key.js +47 -0
- package/build/commands/main.js +36 -0
- package/build/commands/make/_base.d.ts +6 -0
- package/build/commands/make/_base.js +19 -0
- package/build/commands/make/command.d.ts +8 -0
- package/build/commands/make/command.js +25 -0
- package/build/commands/make/controller.d.ts +12 -0
- package/build/commands/make/controller.js +57 -0
- package/build/commands/make/event.d.ts +8 -0
- package/build/commands/make/event.js +25 -0
- package/build/commands/make/listener.d.ts +10 -0
- package/build/commands/make/listener.js +48 -0
- package/build/commands/make/middleware.d.ts +8 -0
- package/build/commands/make/middleware.js +25 -0
- package/build/commands/make/provider.d.ts +8 -0
- package/build/commands/make/provider.js +25 -0
- package/build/index.d.ts +140 -0
- package/build/index.js +21 -0
- package/build/legacy/validator.d.ts +1 -0
- package/build/legacy/validator.js +1 -0
- package/build/modules/ace/commands.d.ts +26 -0
- package/build/modules/ace/commands.js +63 -0
- package/build/modules/ace/create_kernel.d.ts +3 -0
- package/build/modules/ace/create_kernel.js +33 -0
- package/build/modules/ace/kernel.d.ts +7 -0
- package/build/modules/ace/kernel.js +14 -0
- package/build/modules/ace/main.d.ts +3 -0
- package/build/modules/ace/main.js +3 -0
- package/build/modules/app.d.ts +1 -0
- package/build/modules/app.js +1 -0
- package/build/modules/bodyparser/bodyparser_middleware.d.ts +2 -0
- package/build/modules/bodyparser/bodyparser_middleware.js +2 -0
- package/build/modules/bodyparser/main.d.ts +1 -0
- package/build/modules/bodyparser/main.js +1 -0
- package/build/modules/config.d.ts +1 -0
- package/build/modules/config.js +1 -0
- package/build/modules/container.d.ts +1 -0
- package/build/modules/container.js +1 -0
- package/build/modules/encryption.d.ts +1 -0
- package/build/modules/encryption.js +1 -0
- package/build/modules/env.d.ts +1 -0
- package/build/modules/env.js +1 -0
- package/build/modules/events.d.ts +1 -0
- package/build/modules/events.js +1 -0
- package/build/modules/hash/define_config.d.ts +15 -0
- package/build/modules/hash/define_config.js +19 -0
- package/build/modules/hash/drivers_collection.d.ts +9 -0
- package/build/modules/hash/drivers_collection.js +22 -0
- package/build/modules/hash/main.d.ts +2 -0
- package/build/modules/hash/main.js +2 -0
- package/build/modules/http.d.ts +1 -0
- package/build/modules/http.js +1 -0
- package/build/modules/logger.d.ts +1 -0
- package/build/modules/logger.js +1 -0
- package/build/providers/app_provider.d.ts +16 -0
- package/build/providers/app_provider.js +74 -0
- package/build/providers/hash_provider.d.ts +9 -0
- package/build/providers/hash_provider.js +29 -0
- package/build/providers/http_provider.d.ts +9 -0
- package/build/providers/http_provider.js +36 -0
- package/build/services/ace.d.ts +3 -0
- package/build/services/ace.js +6 -0
- package/build/services/app.d.ts +4 -12
- package/build/services/app.js +5 -12
- package/build/services/config.d.ts +3 -3
- package/build/services/config.js +6 -12
- package/build/services/emitter.d.ts +3 -0
- package/build/services/emitter.js +7 -0
- package/build/services/encryption.d.ts +3 -3
- package/build/services/encryption.js +7 -12
- package/build/services/hash.d.ts +3 -3
- package/build/services/hash.js +7 -12
- package/build/services/logger.d.ts +3 -0
- package/build/services/logger.js +7 -0
- package/build/services/router.d.ts +3 -0
- package/build/services/router.js +7 -0
- package/build/services/server.d.ts +3 -0
- package/build/services/server.js +7 -0
- package/build/services/test_utils.d.ts +3 -0
- package/build/services/test_utils.js +6 -0
- package/build/src/debug.d.ts +3 -0
- package/build/src/debug.js +2 -0
- package/build/src/helpers/is.d.ts +2 -0
- package/build/src/helpers/is.js +2 -0
- package/build/src/helpers/main.d.ts +2 -0
- package/build/src/helpers/main.js +2 -0
- package/build/src/helpers/string.d.ts +17 -0
- package/build/src/helpers/string.js +26 -0
- package/build/src/helpers/string_builder.d.ts +23 -0
- package/build/src/helpers/string_builder.js +86 -0
- package/build/src/helpers/types.d.ts +24 -0
- package/build/src/helpers/types.js +29 -0
- package/build/src/ignitor/ace.d.ts +8 -0
- package/build/src/ignitor/ace.js +31 -0
- package/build/src/ignitor/http.d.ts +10 -0
- package/build/src/ignitor/http.js +62 -0
- package/build/src/ignitor/main.d.ts +17 -0
- package/build/src/ignitor/main.js +45 -0
- package/build/src/ignitor/test.d.ts +8 -0
- package/build/src/ignitor/test.js +18 -0
- package/build/src/test_utils/http.d.ts +10 -0
- package/build/src/test_utils/http.js +42 -0
- package/build/src/test_utils/main.d.ts +19 -0
- package/build/src/test_utils/main.js +33 -0
- package/build/src/types.d.ts +63 -0
- package/build/src/types.js +1 -0
- package/build/stubs/index.d.ts +1 -0
- package/build/stubs/index.js +2 -0
- package/build/stubs/make/command/main.stub +19 -0
- package/build/stubs/make/controller/api.stub +33 -0
- package/build/stubs/make/controller/main.stub +9 -0
- package/build/stubs/make/controller/resource.stub +43 -0
- package/build/stubs/make/event/main.stub +15 -0
- package/build/stubs/make/listener/for_event.stub +13 -0
- package/build/stubs/make/listener/main.stub +7 -0
- package/build/stubs/make/middleware/main.stub +22 -0
- package/build/stubs/make/provider/main.stub +35 -0
- package/build/types/ace.d.ts +5 -0
- package/build/types/ace.js +1 -0
- package/build/types/app.d.ts +1 -0
- package/build/types/app.js +1 -0
- package/build/types/bodyparser.d.ts +1 -0
- package/build/types/bodyparser.js +1 -0
- package/build/types/container.d.ts +1 -0
- package/build/types/container.js +1 -0
- package/build/types/encryption.d.ts +1 -0
- package/build/types/encryption.js +1 -0
- package/build/types/events.d.ts +1 -0
- package/build/types/events.js +1 -0
- package/build/types/hash.d.ts +1 -0
- package/build/types/hash.js +1 -0
- package/build/types/http.d.ts +1 -0
- package/build/types/http.js +1 -0
- package/build/types/logger.d.ts +1 -0
- package/build/types/logger.js +1 -0
- package/package.json +226 -245
- package/build/adonis-typings/ace.d.ts +0 -5
- package/build/adonis-typings/ace.js +0 -8
- package/build/adonis-typings/assets-manager.d.ts +0 -88
- package/build/adonis-typings/assets-manager.js +0 -8
- package/build/adonis-typings/container.d.ts +0 -14
- package/build/adonis-typings/container.js +0 -8
- package/build/adonis-typings/cors.d.ts +0 -15
- package/build/adonis-typings/cors.js +0 -8
- package/build/adonis-typings/exception-handler.d.ts +0 -31
- package/build/adonis-typings/exception-handler.js +0 -8
- package/build/adonis-typings/health-check.d.ts +0 -40
- package/build/adonis-typings/health-check.js +0 -8
- package/build/adonis-typings/index.d.ts +0 -17
- package/build/adonis-typings/index.js +0 -25
- package/build/adonis-typings/static.d.ts +0 -15
- package/build/adonis-typings/static.js +0 -8
- package/build/adonis-typings/test-utils.d.ts +0 -24
- package/build/adonis-typings/test-utils.js +0 -8
- package/build/adonis-typings/tests.d.ts +0 -13
- package/build/adonis-typings/tests.js +0 -11
- package/build/commands/DumpRc.d.ts +0 -13
- package/build/commands/DumpRc.js +0 -33
- package/build/commands/GenerateKey.js +0 -25
- package/build/commands/ListRoutes/Renderers/Base.d.ts +0 -31
- package/build/commands/ListRoutes/Renderers/Base.js +0 -70
- package/build/commands/ListRoutes/Renderers/PrettyRenderer.d.ts +0 -51
- package/build/commands/ListRoutes/Renderers/PrettyRenderer.js +0 -135
- package/build/commands/ListRoutes/Renderers/TableRenderer.d.ts +0 -36
- package/build/commands/ListRoutes/Renderers/TableRenderer.js +0 -137
- package/build/commands/ListRoutes/index.d.ts +0 -75
- package/build/commands/ListRoutes/index.js +0 -166
- package/build/commands/index.d.ts +0 -2
- package/build/commands/index.js +0 -15
- package/build/config.d.ts +0 -2
- package/build/config.js +0 -15
- package/build/instructions.js +0 -81
- package/build/providers/AppProvider.d.ts +0 -68
- package/build/providers/AppProvider.js +0 -201
- package/build/services/base.d.ts +0 -3
- package/build/services/base.js +0 -23
- package/build/services/bodyparser.d.ts +0 -2
- package/build/services/bodyparser.js +0 -12
- package/build/services/drive.d.ts +0 -3
- package/build/services/drive.js +0 -12
- package/build/services/event.d.ts +0 -3
- package/build/services/event.js +0 -12
- package/build/services/healthChecks.d.ts +0 -3
- package/build/services/healthChecks.js +0 -12
- package/build/services/httpContext.d.ts +0 -3
- package/build/services/httpContext.js +0 -12
- package/build/services/route.d.ts +0 -3
- package/build/services/route.js +0 -12
- package/build/services/validator.d.ts +0 -3
- package/build/services/validator.js +0 -12
- package/build/src/AssetsManager/Drivers/Encore.d.ts +0 -78
- package/build/src/AssetsManager/Drivers/Encore.js +0 -148
- package/build/src/AssetsManager/Drivers/Fake.d.ts +0 -37
- package/build/src/AssetsManager/Drivers/Fake.js +0 -60
- package/build/src/AssetsManager/index.d.ts +0 -83
- package/build/src/AssetsManager/index.js +0 -171
- package/build/src/Bindings/Repl.d.ts +0 -8
- package/build/src/Bindings/Repl.js +0 -90
- package/build/src/Bindings/Tests.d.ts +0 -7
- package/build/src/Bindings/Tests.js +0 -66
- package/build/src/HealthCheck/Checkers/AppKey.d.ts +0 -6
- package/build/src/HealthCheck/Checkers/AppKey.js +0 -60
- package/build/src/HealthCheck/Checkers/Env.d.ts +0 -6
- package/build/src/HealthCheck/Checkers/Env.js +0 -42
- package/build/src/HealthCheck/index.d.ts +0 -48
- package/build/src/HealthCheck/index.js +0 -99
- package/build/src/Hooks/Cors/index.d.ts +0 -70
- package/build/src/Hooks/Cors/index.js +0 -314
- package/build/src/Hooks/Static/index.d.ts +0 -18
- package/build/src/Hooks/Static/index.js +0 -66
- package/build/src/HttpExceptionHandler/index.d.ts +0 -82
- package/build/src/HttpExceptionHandler/index.js +0 -213
- package/build/src/Ignitor/Ace/App/index.d.ts +0 -60
- package/build/src/Ignitor/Ace/App/index.js +0 -236
- package/build/src/Ignitor/Ace/Exceptions/index.d.ts +0 -4
- package/build/src/Ignitor/Ace/Exceptions/index.js +0 -19
- package/build/src/Ignitor/Ace/GenerateManifest/index.d.ts +0 -28
- package/build/src/Ignitor/Ace/GenerateManifest/index.js +0 -75
- package/build/src/Ignitor/Ace/index.d.ts +0 -11
- package/build/src/Ignitor/Ace/index.js +0 -36
- package/build/src/Ignitor/HttpServer/index.d.ts +0 -56
- package/build/src/Ignitor/HttpServer/index.js +0 -127
- package/build/src/Ignitor/Kernel/index.d.ts +0 -56
- package/build/src/Ignitor/Kernel/index.js +0 -123
- package/build/src/Ignitor/SignalsListener/index.d.ts +0 -23
- package/build/src/Ignitor/SignalsListener/index.js +0 -66
- package/build/src/Ignitor/index.d.ts +0 -32
- package/build/src/Ignitor/index.js +0 -58
- package/build/src/TestUtils/HttpServer/index.d.ts +0 -27
- package/build/src/TestUtils/HttpServer/index.js +0 -56
- package/build/src/TestUtils/index.d.ts +0 -24
- package/build/src/TestUtils/index.js +0 -43
- package/build/src/utils/index.d.ts +0 -18
- package/build/src/utils/index.js +0 -82
- package/build/standalone.d.ts +0 -9
- package/build/standalone.js +0 -52
- package/build/templates/config/app.txt +0 -303
- package/build/templates/config/bodyparser.txt +0 -211
- package/build/templates/config/cors.txt +0 -134
- package/build/templates/config/drive.txt +0 -149
- package/build/templates/config/hash.txt +0 -96
- package/build/templates/config/static.txt +0 -89
- package/build/templates/contracts/drive.txt +0 -13
- package/build/templates/contracts/env.txt +0 -24
- package/build/templates/contracts/events.txt +0 -31
- package/build/templates/contracts/hash.txt +0 -13
- package/build/templates/env.txt +0 -31
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { CustomServerCallback } from '@ioc:Adonis/Core/TestUtils';
|
|
2
|
-
import { AppKernel } from '../Kernel';
|
|
3
|
-
/**
|
|
4
|
-
* Exposes the API to setup the application for starting the HTTP
|
|
5
|
-
* server.
|
|
6
|
-
*
|
|
7
|
-
* - Calling "kill" explicitly exists the process.
|
|
8
|
-
* - The "error" event emitted on the server instance explicitly exists the process.
|
|
9
|
-
* - SIGINT and in some case SIGTERM explicitly exists the process.
|
|
10
|
-
*/
|
|
11
|
-
export declare class HttpServer {
|
|
12
|
-
private appRoot;
|
|
13
|
-
/**
|
|
14
|
-
* Reference to the HTTP server.
|
|
15
|
-
*/
|
|
16
|
-
private server;
|
|
17
|
-
/**
|
|
18
|
-
* Reference to the app kernel
|
|
19
|
-
*/
|
|
20
|
-
kernel: AppKernel;
|
|
21
|
-
application: import("@adonisjs/application").Application;
|
|
22
|
-
constructor(appRoot: string);
|
|
23
|
-
/**
|
|
24
|
-
* Closes the underlying HTTP server
|
|
25
|
-
*/
|
|
26
|
-
private closeHttpServer;
|
|
27
|
-
/**
|
|
28
|
-
* Monitors the HTTP server for close and error events, so that
|
|
29
|
-
* we can perform a graceful shutdown.
|
|
30
|
-
*/
|
|
31
|
-
private monitorHttpServer;
|
|
32
|
-
/**
|
|
33
|
-
* Creates the HTTP server to handle incoming requests. The server is just
|
|
34
|
-
* created but not listening on any port.
|
|
35
|
-
*/
|
|
36
|
-
createServer(serverCallback?: CustomServerCallback): void;
|
|
37
|
-
/**
|
|
38
|
-
* Starts the http server a given host and port
|
|
39
|
-
*/
|
|
40
|
-
listen(): Promise<void>;
|
|
41
|
-
/**
|
|
42
|
-
* Start the HTTP server by wiring up the application
|
|
43
|
-
*/
|
|
44
|
-
start(serverCallback?: CustomServerCallback): Promise<void>;
|
|
45
|
-
/**
|
|
46
|
-
* Prepares the application for shutdown. This method will invoke `shutdown`
|
|
47
|
-
* lifecycle method on the providers and closes the `httpServer`.
|
|
48
|
-
*/
|
|
49
|
-
close(): Promise<void>;
|
|
50
|
-
/**
|
|
51
|
-
* Kills the http server process by attempting to perform a graceful
|
|
52
|
-
* shutdown or killing the app forcefully as waiting for configured
|
|
53
|
-
* seconds.
|
|
54
|
-
*/
|
|
55
|
-
kill(waitTimeout?: number): Promise<void>;
|
|
56
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* @adonisjs/core
|
|
4
|
-
*
|
|
5
|
-
* (c) Harminder Virk <virk@adonisjs.com>
|
|
6
|
-
*
|
|
7
|
-
* For the full copyright and license information, please view the LICENSE
|
|
8
|
-
* file that was distributed with this source code.
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.HttpServer = void 0;
|
|
12
|
-
const Kernel_1 = require("../Kernel");
|
|
13
|
-
const utils_1 = require("../../utils");
|
|
14
|
-
/**
|
|
15
|
-
* Exposes the API to setup the application for starting the HTTP
|
|
16
|
-
* server.
|
|
17
|
-
*
|
|
18
|
-
* - Calling "kill" explicitly exists the process.
|
|
19
|
-
* - The "error" event emitted on the server instance explicitly exists the process.
|
|
20
|
-
* - SIGINT and in some case SIGTERM explicitly exists the process.
|
|
21
|
-
*/
|
|
22
|
-
class HttpServer {
|
|
23
|
-
constructor(appRoot) {
|
|
24
|
-
this.appRoot = appRoot;
|
|
25
|
-
/**
|
|
26
|
-
* Reference to the app kernel
|
|
27
|
-
*/
|
|
28
|
-
this.kernel = new Kernel_1.AppKernel(this.appRoot, 'web');
|
|
29
|
-
this.application = this.kernel.application;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Closes the underlying HTTP server
|
|
33
|
-
*/
|
|
34
|
-
closeHttpServer() {
|
|
35
|
-
return new Promise((resolve) => this.server.instance.close(() => resolve()));
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Monitors the HTTP server for close and error events, so that
|
|
39
|
-
* we can perform a graceful shutdown.
|
|
40
|
-
*/
|
|
41
|
-
monitorHttpServer() {
|
|
42
|
-
this.server.instance.on('close', async () => {
|
|
43
|
-
this.application.logger.trace('closing http server');
|
|
44
|
-
this.server.instance.removeAllListeners();
|
|
45
|
-
this.application.isShuttingDown = true;
|
|
46
|
-
});
|
|
47
|
-
this.server.instance.on('error', async (error) => {
|
|
48
|
-
this.application.logger.error(error, error.message);
|
|
49
|
-
await this.kill(3000);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Creates the HTTP server to handle incoming requests. The server is just
|
|
54
|
-
* created but not listening on any port.
|
|
55
|
-
*/
|
|
56
|
-
createServer(serverCallback) {
|
|
57
|
-
this.server = this.application.container.use('Adonis/Core/Server');
|
|
58
|
-
(0, utils_1.createHttpServer)(this.application, this.server, serverCallback);
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Starts the http server a given host and port
|
|
62
|
-
*/
|
|
63
|
-
listen() {
|
|
64
|
-
return new Promise(async (resolve, reject) => {
|
|
65
|
-
try {
|
|
66
|
-
await this.kernel.start(() => this.close());
|
|
67
|
-
const host = this.application.env.get('HOST', '0.0.0.0');
|
|
68
|
-
const port = Number(this.application.env.get('PORT', '3333'));
|
|
69
|
-
this.server.instance.listen(port, host, () => {
|
|
70
|
-
this.application.logger.info('started server on %s:%s', host, port);
|
|
71
|
-
this.kernel.ready({ port: port, host: host });
|
|
72
|
-
resolve();
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
reject(error);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Start the HTTP server by wiring up the application
|
|
82
|
-
*/
|
|
83
|
-
async start(serverCallback) {
|
|
84
|
-
try {
|
|
85
|
-
await this.kernel.boot();
|
|
86
|
-
this.createServer(serverCallback);
|
|
87
|
-
this.monitorHttpServer();
|
|
88
|
-
await this.listen();
|
|
89
|
-
}
|
|
90
|
-
catch (error) {
|
|
91
|
-
await this.kernel.handleError(error);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Prepares the application for shutdown. This method will invoke `shutdown`
|
|
96
|
-
* lifecycle method on the providers and closes the `httpServer`.
|
|
97
|
-
*/
|
|
98
|
-
async close() {
|
|
99
|
-
/**
|
|
100
|
-
* Close the HTTP server before excuting the `shutdown` hooks. This ensures that
|
|
101
|
-
* we are not accepting any new request during cool off.
|
|
102
|
-
*/
|
|
103
|
-
await this.closeHttpServer();
|
|
104
|
-
await this.kernel.close();
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Kills the http server process by attempting to perform a graceful
|
|
108
|
-
* shutdown or killing the app forcefully as waiting for configured
|
|
109
|
-
* seconds.
|
|
110
|
-
*/
|
|
111
|
-
async kill(waitTimeout = 3000) {
|
|
112
|
-
this.application.logger.trace('forcefully killing http server');
|
|
113
|
-
try {
|
|
114
|
-
await Promise.race([
|
|
115
|
-
this.close(),
|
|
116
|
-
new Promise((resolve) => {
|
|
117
|
-
setTimeout(resolve, waitTimeout);
|
|
118
|
-
}),
|
|
119
|
-
]);
|
|
120
|
-
process.exit(0);
|
|
121
|
-
}
|
|
122
|
-
catch (error) {
|
|
123
|
-
await this.kernel.handleError(error).finally(() => process.exit(1));
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
exports.HttpServer = HttpServer;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Application } from '@adonisjs/application';
|
|
2
|
-
import { AppEnvironments } from '@ioc:Adonis/Core/Application';
|
|
3
|
-
import { SignalsListener } from '../SignalsListener';
|
|
4
|
-
/**
|
|
5
|
-
* Kernel to manage application state
|
|
6
|
-
*/
|
|
7
|
-
export declare class AppKernel {
|
|
8
|
-
/**
|
|
9
|
-
* Reference to application instance
|
|
10
|
-
*/
|
|
11
|
-
application: Application;
|
|
12
|
-
/**
|
|
13
|
-
* Reference to signals listener
|
|
14
|
-
*/
|
|
15
|
-
signalsListener: SignalsListener;
|
|
16
|
-
/**
|
|
17
|
-
* Find if the application has been booted or not
|
|
18
|
-
*/
|
|
19
|
-
hasBooted: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Avoiding duplicate registeration of ts compiler hook
|
|
22
|
-
*/
|
|
23
|
-
private hasRegisteredTsHook;
|
|
24
|
-
constructor(appRoot: string, environment: AppEnvironments);
|
|
25
|
-
/**
|
|
26
|
-
* Pretty prints a given error on the terminal
|
|
27
|
-
*/
|
|
28
|
-
private prettyPrintError;
|
|
29
|
-
/**
|
|
30
|
-
* Boot the application. The process for booting the app remains the
|
|
31
|
-
* same regardless of the process environment.
|
|
32
|
-
*/
|
|
33
|
-
boot(): Promise<void>;
|
|
34
|
-
/**
|
|
35
|
-
* Registers the TS compiler to hook into node require and
|
|
36
|
-
* process TypeScript files
|
|
37
|
-
*/
|
|
38
|
-
registerTsCompilerHook(): void;
|
|
39
|
-
/**
|
|
40
|
-
* Start the application. The callback is required to listen
|
|
41
|
-
* for close signals
|
|
42
|
-
*/
|
|
43
|
-
start(shutdownCallback?: () => Promise<void>): Promise<() => Promise<void>>;
|
|
44
|
-
/**
|
|
45
|
-
* Notify that process is ready
|
|
46
|
-
*/
|
|
47
|
-
ready(eventPayload: Record<string, any>): void;
|
|
48
|
-
/**
|
|
49
|
-
* Prepare application for shutdown
|
|
50
|
-
*/
|
|
51
|
-
close(): Promise<void>;
|
|
52
|
-
/**
|
|
53
|
-
* Handles ignitor boot errors
|
|
54
|
-
*/
|
|
55
|
-
handleError(error: any): Promise<void>;
|
|
56
|
-
}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* @adonisjs/core
|
|
4
|
-
*
|
|
5
|
-
* (c) Harminder Virk <virk@adonisjs.com>
|
|
6
|
-
*
|
|
7
|
-
* For the full copyright and license information, please view the LICENSE
|
|
8
|
-
* file that was distributed with this source code.
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.AppKernel = void 0;
|
|
12
|
-
const application_1 = require("@adonisjs/application");
|
|
13
|
-
const utils_1 = require("../../utils");
|
|
14
|
-
const SignalsListener_1 = require("../SignalsListener");
|
|
15
|
-
/**
|
|
16
|
-
* Kernel to manage application state
|
|
17
|
-
*/
|
|
18
|
-
class AppKernel {
|
|
19
|
-
constructor(appRoot, environment) {
|
|
20
|
-
/**
|
|
21
|
-
* Find if the application has been booted or not
|
|
22
|
-
*/
|
|
23
|
-
this.hasBooted = false;
|
|
24
|
-
/**
|
|
25
|
-
* Avoiding duplicate registeration of ts compiler hook
|
|
26
|
-
*/
|
|
27
|
-
this.hasRegisteredTsHook = false;
|
|
28
|
-
this.application = new application_1.Application(appRoot, environment);
|
|
29
|
-
this.signalsListener = new SignalsListener_1.SignalsListener(this.application);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Pretty prints a given error on the terminal
|
|
33
|
-
*/
|
|
34
|
-
async prettyPrintError(error) {
|
|
35
|
-
try {
|
|
36
|
-
const Youch = require('youch');
|
|
37
|
-
const output = await new Youch(error, {}).toJSON();
|
|
38
|
-
console.log(require('youch-terminal')(output));
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
console.log(error.stack);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Boot the application. The process for booting the app remains the
|
|
46
|
-
* same regardless of the process environment.
|
|
47
|
-
*/
|
|
48
|
-
async boot() {
|
|
49
|
-
if (this.hasBooted) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Setting up the application.
|
|
54
|
-
*/
|
|
55
|
-
await this.application.setup();
|
|
56
|
-
/**
|
|
57
|
-
* Registering providers
|
|
58
|
-
*/
|
|
59
|
-
await this.application.registerProviders();
|
|
60
|
-
/**
|
|
61
|
-
* Booting providers
|
|
62
|
-
*/
|
|
63
|
-
await this.application.bootProviders();
|
|
64
|
-
/**
|
|
65
|
-
* Importing preloaded files
|
|
66
|
-
*/
|
|
67
|
-
await this.application.requirePreloads();
|
|
68
|
-
this.hasBooted = true;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Registers the TS compiler to hook into node require and
|
|
72
|
-
* process TypeScript files
|
|
73
|
-
*/
|
|
74
|
-
registerTsCompilerHook() {
|
|
75
|
-
/**
|
|
76
|
-
* Register ts hook when running typescript code directly
|
|
77
|
-
*/
|
|
78
|
-
if (this.application.rcFile.typescript && !this.hasRegisteredTsHook) {
|
|
79
|
-
this.hasRegisteredTsHook = true;
|
|
80
|
-
(0, utils_1.registerTsHook)(this.application.appRoot);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Start the application. The callback is required to listen
|
|
85
|
-
* for close signals
|
|
86
|
-
*/
|
|
87
|
-
async start(shutdownCallback) {
|
|
88
|
-
await this.application.start();
|
|
89
|
-
this.signalsListener.listen(shutdownCallback || (() => this.close()));
|
|
90
|
-
return () => this.close();
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Notify that process is ready
|
|
94
|
-
*/
|
|
95
|
-
ready(eventPayload) {
|
|
96
|
-
if (process.send) {
|
|
97
|
-
process.send('ready');
|
|
98
|
-
process.send({ isAdonisJS: true, environment: this.application.environment, ...eventPayload });
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Prepare application for shutdown
|
|
103
|
-
*/
|
|
104
|
-
async close() {
|
|
105
|
-
this.signalsListener.cleanup();
|
|
106
|
-
await this.application.shutdown();
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Handles ignitor boot errors
|
|
110
|
-
*/
|
|
111
|
-
async handleError(error) {
|
|
112
|
-
if (typeof error.handle === 'function') {
|
|
113
|
-
await error.handle(error);
|
|
114
|
-
}
|
|
115
|
-
else if (this.application.inDev) {
|
|
116
|
-
await this.prettyPrintError(error);
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
console.error(error.stack);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
exports.AppKernel = AppKernel;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { ApplicationContract } from '@ioc:Adonis/Core/Application';
|
|
2
|
-
/**
|
|
3
|
-
* Exposes the API to invoke a callback when `SIGTERM` or
|
|
4
|
-
* `SIGINT (pm2 only)` signals are received.
|
|
5
|
-
*/
|
|
6
|
-
export declare class SignalsListener {
|
|
7
|
-
private application;
|
|
8
|
-
protected onCloseCallback?: () => Promise<void>;
|
|
9
|
-
/**
|
|
10
|
-
* Invoke callback and exit process
|
|
11
|
-
*/
|
|
12
|
-
private kill;
|
|
13
|
-
constructor(application: ApplicationContract);
|
|
14
|
-
/**
|
|
15
|
-
* Listens for exit signals and invokes the given
|
|
16
|
-
* callback
|
|
17
|
-
*/
|
|
18
|
-
listen(callback: () => Promise<void>): void;
|
|
19
|
-
/**
|
|
20
|
-
* Cleanup event listeners
|
|
21
|
-
*/
|
|
22
|
-
cleanup(): void;
|
|
23
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* @adonisjs/core
|
|
4
|
-
*
|
|
5
|
-
* (c) Harminder Virk <virk@adonisjs.com>
|
|
6
|
-
*
|
|
7
|
-
* For the full copyright and license information, please view the LICENSE
|
|
8
|
-
* file that was distributed with this source code.
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.SignalsListener = void 0;
|
|
12
|
-
/**
|
|
13
|
-
* Exposes the API to invoke a callback when `SIGTERM` or
|
|
14
|
-
* `SIGINT (pm2 only)` signals are received.
|
|
15
|
-
*/
|
|
16
|
-
class SignalsListener {
|
|
17
|
-
constructor(application) {
|
|
18
|
-
this.application = application;
|
|
19
|
-
/**
|
|
20
|
-
* Invoke callback and exit process
|
|
21
|
-
*/
|
|
22
|
-
this.kill = async function () {
|
|
23
|
-
try {
|
|
24
|
-
await Promise.race([
|
|
25
|
-
this.onCloseCallback(),
|
|
26
|
-
new Promise((resolve) => {
|
|
27
|
-
setTimeout(resolve, 3000);
|
|
28
|
-
}),
|
|
29
|
-
]);
|
|
30
|
-
process.exit(0);
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
process.exit(1);
|
|
34
|
-
}
|
|
35
|
-
}.bind(this);
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Listens for exit signals and invokes the given
|
|
39
|
-
* callback
|
|
40
|
-
*/
|
|
41
|
-
listen(callback) {
|
|
42
|
-
this.onCloseCallback = callback;
|
|
43
|
-
/**
|
|
44
|
-
* Close on SIGINT AND SIGTERM SIGNALS
|
|
45
|
-
*/
|
|
46
|
-
if (process.env.pm_id) {
|
|
47
|
-
process.on('SIGINT', this.kill);
|
|
48
|
-
}
|
|
49
|
-
process.on('SIGTERM', this.kill);
|
|
50
|
-
/**
|
|
51
|
-
* Notify about uncaught exceptions
|
|
52
|
-
*/
|
|
53
|
-
process.on('uncaughtExceptionMonitor', (error) => {
|
|
54
|
-
this.application.logger.fatal(error, '"uncaughtException" detected');
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Cleanup event listeners
|
|
59
|
-
*/
|
|
60
|
-
cleanup() {
|
|
61
|
-
process.removeListener('SIGINT', this.kill);
|
|
62
|
-
process.removeListener('SIGTERM', this.kill);
|
|
63
|
-
this.onCloseCallback = undefined;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
exports.SignalsListener = SignalsListener;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Application } from '@adonisjs/application';
|
|
2
|
-
import { AppEnvironments } from '@ioc:Adonis/Core/Application';
|
|
3
|
-
import { Ace } from './Ace';
|
|
4
|
-
import { HttpServer } from './HttpServer';
|
|
5
|
-
import { AppKernel } from './Kernel';
|
|
6
|
-
/**
|
|
7
|
-
* Ignitor is used to wireup different pieces of AdonisJs to bootstrap
|
|
8
|
-
* the application.
|
|
9
|
-
*/
|
|
10
|
-
export declare class Ignitor {
|
|
11
|
-
private appRoot;
|
|
12
|
-
constructor(appRoot: string);
|
|
13
|
-
/**
|
|
14
|
-
* Returns an instance of the application.
|
|
15
|
-
*/
|
|
16
|
-
application(environment: AppEnvironments): Application;
|
|
17
|
-
/**
|
|
18
|
-
* Returns instance of server to start
|
|
19
|
-
* the HTTP server
|
|
20
|
-
*/
|
|
21
|
-
httpServer(): HttpServer;
|
|
22
|
-
/**
|
|
23
|
-
* Returns instance of server to start
|
|
24
|
-
* the HTTP server
|
|
25
|
-
*/
|
|
26
|
-
kernel(environment: AppEnvironments): AppKernel;
|
|
27
|
-
/**
|
|
28
|
-
* Returns instance of ace to handle console
|
|
29
|
-
* commands
|
|
30
|
-
*/
|
|
31
|
-
ace(): Ace;
|
|
32
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Ignitor = void 0;
|
|
4
|
-
/*
|
|
5
|
-
* @adonisjs/core
|
|
6
|
-
*
|
|
7
|
-
* (c) Harminder Virk <virk@adonisjs.com>
|
|
8
|
-
*
|
|
9
|
-
* For the full copyright and license information, please view the LICENSE
|
|
10
|
-
* file that was distributed with this source code.
|
|
11
|
-
*/
|
|
12
|
-
const path_1 = require("path");
|
|
13
|
-
const url_1 = require("url");
|
|
14
|
-
const application_1 = require("@adonisjs/application");
|
|
15
|
-
const Ace_1 = require("./Ace");
|
|
16
|
-
const HttpServer_1 = require("./HttpServer");
|
|
17
|
-
const Kernel_1 = require("./Kernel");
|
|
18
|
-
/**
|
|
19
|
-
* Ignitor is used to wireup different pieces of AdonisJs to bootstrap
|
|
20
|
-
* the application.
|
|
21
|
-
*/
|
|
22
|
-
class Ignitor {
|
|
23
|
-
constructor(appRoot) {
|
|
24
|
-
/**
|
|
25
|
-
* In ESM, ignitor is constructed with `import.meta.url`. Normalize
|
|
26
|
-
* the file URL to an absolute directory path.
|
|
27
|
-
*/
|
|
28
|
-
this.appRoot = appRoot.startsWith('file:') ? (0, path_1.dirname)((0, url_1.fileURLToPath)(appRoot)) : appRoot;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Returns an instance of the application.
|
|
32
|
-
*/
|
|
33
|
-
application(environment) {
|
|
34
|
-
return new application_1.Application(this.appRoot, environment);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Returns instance of server to start
|
|
38
|
-
* the HTTP server
|
|
39
|
-
*/
|
|
40
|
-
httpServer() {
|
|
41
|
-
return new HttpServer_1.HttpServer(this.appRoot);
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Returns instance of server to start
|
|
45
|
-
* the HTTP server
|
|
46
|
-
*/
|
|
47
|
-
kernel(environment) {
|
|
48
|
-
return new Kernel_1.AppKernel(this.appRoot, environment);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Returns instance of ace to handle console
|
|
52
|
-
* commands
|
|
53
|
-
*/
|
|
54
|
-
ace() {
|
|
55
|
-
return new Ace_1.Ace(this.appRoot);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
exports.Ignitor = Ignitor;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { ApplicationContract } from '@ioc:Adonis/Core/Application';
|
|
2
|
-
import { CustomServerCallback } from '@ioc:Adonis/Core/TestUtils';
|
|
3
|
-
/**
|
|
4
|
-
* The test HTTP server to handle and serve HTTP request
|
|
5
|
-
*/
|
|
6
|
-
export declare class TestHttpServer {
|
|
7
|
-
application: ApplicationContract;
|
|
8
|
-
private server;
|
|
9
|
-
constructor(application: ApplicationContract);
|
|
10
|
-
/**
|
|
11
|
-
* Creates the HTTP server to handle incoming requests. The server is just
|
|
12
|
-
* created but not listening on any port.
|
|
13
|
-
*/
|
|
14
|
-
private create;
|
|
15
|
-
/**
|
|
16
|
-
* Start the HTTP server to listen for incoming requests
|
|
17
|
-
*/
|
|
18
|
-
private listen;
|
|
19
|
-
/**
|
|
20
|
-
* Close HTTP server from listening to any requests
|
|
21
|
-
*/
|
|
22
|
-
close(): Promise<void>;
|
|
23
|
-
/**
|
|
24
|
-
* Start the test HTTP server
|
|
25
|
-
*/
|
|
26
|
-
start(serverCallback?: CustomServerCallback): Promise<() => Promise<void>>;
|
|
27
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* @adonisjs/core
|
|
4
|
-
*
|
|
5
|
-
* (c) Harminder Virk <virk@adonisjs.com>
|
|
6
|
-
*
|
|
7
|
-
* For the full copyright and license information, please view the LICENSE
|
|
8
|
-
* file that was distributed with this source code.
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.TestHttpServer = void 0;
|
|
12
|
-
const utils_1 = require("../../utils");
|
|
13
|
-
/**
|
|
14
|
-
* The test HTTP server to handle and serve HTTP request
|
|
15
|
-
*/
|
|
16
|
-
class TestHttpServer {
|
|
17
|
-
constructor(application) {
|
|
18
|
-
this.application = application;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Creates the HTTP server to handle incoming requests. The server is just
|
|
22
|
-
* created but not listening on any port.
|
|
23
|
-
*/
|
|
24
|
-
create(serverCallback) {
|
|
25
|
-
this.server = this.application.container.use('Adonis/Core/Server');
|
|
26
|
-
(0, utils_1.createHttpServer)(this.application, this.server, serverCallback);
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Start the HTTP server to listen for incoming requests
|
|
30
|
-
*/
|
|
31
|
-
listen() {
|
|
32
|
-
const host = this.application.env.get('HOST', '0.0.0.0');
|
|
33
|
-
const port = Number(this.application.env.get('PORT', '3333'));
|
|
34
|
-
return new Promise((resolve) => {
|
|
35
|
-
this.server.instance.listen(port, host, () => {
|
|
36
|
-
this.application.logger.info('started server on %s:%s', host, port);
|
|
37
|
-
resolve();
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Close HTTP server from listening to any requests
|
|
43
|
-
*/
|
|
44
|
-
close() {
|
|
45
|
-
return new Promise((resolve) => this.server.instance.close(() => resolve()));
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Start the test HTTP server
|
|
49
|
-
*/
|
|
50
|
-
async start(serverCallback) {
|
|
51
|
-
this.create(serverCallback);
|
|
52
|
-
await this.listen();
|
|
53
|
-
return () => this.close();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
exports.TestHttpServer = TestHttpServer;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Macroable } from 'macroable';
|
|
2
|
-
import { TestUtilsContract } from '@ioc:Adonis/Core/TestUtils';
|
|
3
|
-
import { ApplicationContract } from '@ioc:Adonis/Core/Application';
|
|
4
|
-
import { TestHttpServer } from './HttpServer';
|
|
5
|
-
/**
|
|
6
|
-
* Test utils module is meant to be extended to add custom
|
|
7
|
-
* utilities required for testing AdonisJS applications.
|
|
8
|
-
*/
|
|
9
|
-
export declare class TestUtils extends Macroable implements Omit<TestUtilsContract, 'constructor'> {
|
|
10
|
-
application: ApplicationContract;
|
|
11
|
-
static macros: {};
|
|
12
|
-
static getters: {};
|
|
13
|
-
constructor(application: ApplicationContract);
|
|
14
|
-
/**
|
|
15
|
-
* Utilities for ace
|
|
16
|
-
*/
|
|
17
|
-
ace(): {
|
|
18
|
-
loadCommands: () => Promise<void>;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Utilities for http server
|
|
22
|
-
*/
|
|
23
|
-
httpServer(): TestHttpServer;
|
|
24
|
-
}
|