@adonisjs/core 5.9.0 → 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 -92
- 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/Base.d.ts +0 -27
- package/build/src/AssetsManager/Drivers/Base.js +0 -66
- package/build/src/AssetsManager/Drivers/Encore.d.ts +0 -58
- package/build/src/AssetsManager/Drivers/Encore.js +0 -93
- package/build/src/AssetsManager/Drivers/Fake.d.ts +0 -38
- package/build/src/AssetsManager/Drivers/Fake.js +0 -61
- package/build/src/AssetsManager/Drivers/Vite.d.ts +0 -84
- package/build/src/AssetsManager/Drivers/Vite.js +0 -139
- package/build/src/AssetsManager/index.d.ts +0 -87
- package/build/src/AssetsManager/index.js +0 -184
- 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,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* @adonisjs/core
|
|
4
|
-
*
|
|
5
|
-
* (c) AdonisJS
|
|
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.defineTestsBindings = void 0;
|
|
12
|
-
/**
|
|
13
|
-
* Define test bindings
|
|
14
|
-
*/
|
|
15
|
-
function defineTestsBindings(ApiRequest, ApiClient, CookieClient) {
|
|
16
|
-
/**
|
|
17
|
-
* Serializing for parsing response cookies
|
|
18
|
-
*/
|
|
19
|
-
ApiClient.cookiesSerializer({
|
|
20
|
-
/**
|
|
21
|
-
* The methods on the Request class encrypts and signs cookies.
|
|
22
|
-
* Therefore, the prepare method returns the value as it is
|
|
23
|
-
*/
|
|
24
|
-
prepare(_, value) {
|
|
25
|
-
return value;
|
|
26
|
-
},
|
|
27
|
-
/**
|
|
28
|
-
* Process the server response and convert cookie value to a
|
|
29
|
-
* plain string
|
|
30
|
-
*/
|
|
31
|
-
process(key, value) {
|
|
32
|
-
return CookieClient.parse(key, value);
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
/**
|
|
36
|
-
* Define cookie
|
|
37
|
-
*/
|
|
38
|
-
ApiRequest.macro('cookie', function (key, value) {
|
|
39
|
-
const signedValue = CookieClient.sign(key, value);
|
|
40
|
-
if (signedValue) {
|
|
41
|
-
this.cookiesJar[key] = { name: key, value: signedValue };
|
|
42
|
-
}
|
|
43
|
-
return this;
|
|
44
|
-
});
|
|
45
|
-
/**
|
|
46
|
-
* Define encrypted cookie
|
|
47
|
-
*/
|
|
48
|
-
ApiRequest.macro('encryptedCookie', function (key, value) {
|
|
49
|
-
const encryptedValue = CookieClient.encrypt(key, value);
|
|
50
|
-
if (encryptedValue) {
|
|
51
|
-
this.cookiesJar[key] = { name: key, value: encryptedValue };
|
|
52
|
-
}
|
|
53
|
-
return this;
|
|
54
|
-
});
|
|
55
|
-
/**
|
|
56
|
-
* Define plain cookie
|
|
57
|
-
*/
|
|
58
|
-
ApiRequest.macro('plainCookie', function (key, value) {
|
|
59
|
-
const encodedValue = CookieClient.encode(key, value);
|
|
60
|
-
if (encodedValue) {
|
|
61
|
-
this.cookiesJar[key] = { name: key, value: encodedValue };
|
|
62
|
-
}
|
|
63
|
-
return this;
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
exports.defineTestsBindings = defineTestsBindings;
|
|
@@ -1,60 +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
|
-
/**
|
|
12
|
-
* Message for missing Api Key
|
|
13
|
-
*/
|
|
14
|
-
const MISSING_APP_KEY_MESSAGE = [
|
|
15
|
-
'Missing APP_KEY environment variable.',
|
|
16
|
-
'It is required to keep your application secure',
|
|
17
|
-
].join(' ');
|
|
18
|
-
/**
|
|
19
|
-
* Message for insecure Api Key
|
|
20
|
-
*/
|
|
21
|
-
const INSECURE_APP_KEY_MESSAGE = [
|
|
22
|
-
'Insecure APP_KEY.',
|
|
23
|
-
'It must be 32 characters long.',
|
|
24
|
-
'Run "node ace generate:key" to generate a secure key',
|
|
25
|
-
].join(' ');
|
|
26
|
-
const DISPLAY_NAME = 'App Key Check';
|
|
27
|
-
/**
|
|
28
|
-
* Check for the APP_KEY to ensure it is present and has
|
|
29
|
-
* desired length.
|
|
30
|
-
*/
|
|
31
|
-
function addAppKeyChecker(healthCheck) {
|
|
32
|
-
healthCheck.addChecker('appKey', async () => {
|
|
33
|
-
const appKey = process.env.APP_KEY;
|
|
34
|
-
if (!appKey) {
|
|
35
|
-
return {
|
|
36
|
-
displayName: DISPLAY_NAME,
|
|
37
|
-
health: {
|
|
38
|
-
healthy: false,
|
|
39
|
-
message: MISSING_APP_KEY_MESSAGE,
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
if (appKey && appKey.length < 32) {
|
|
44
|
-
return {
|
|
45
|
-
displayName: DISPLAY_NAME,
|
|
46
|
-
health: {
|
|
47
|
-
healthy: false,
|
|
48
|
-
message: INSECURE_APP_KEY_MESSAGE,
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
return {
|
|
53
|
-
displayName: DISPLAY_NAME,
|
|
54
|
-
health: {
|
|
55
|
-
healthy: true,
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
exports.default = addAppKeyChecker;
|
|
@@ -1,42 +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
|
-
/**
|
|
12
|
-
* Message for missing app key
|
|
13
|
-
*/
|
|
14
|
-
const MISSING_NODE_ENV_MESSAGE = [
|
|
15
|
-
'Missing NODE_ENV environment variable.',
|
|
16
|
-
'It can make some parts of the application misbehave',
|
|
17
|
-
].join(' ');
|
|
18
|
-
const DISPLAY_NAME = 'Node Env Check';
|
|
19
|
-
/**
|
|
20
|
-
* Register the `env` checker to ensure that `NODE_ENV` environment
|
|
21
|
-
* variable is defined.
|
|
22
|
-
*/
|
|
23
|
-
function addEnvChecker(healthCheck) {
|
|
24
|
-
healthCheck.addChecker('env', async () => {
|
|
25
|
-
const env = process.env.NODE_ENV;
|
|
26
|
-
return env
|
|
27
|
-
? {
|
|
28
|
-
displayName: DISPLAY_NAME,
|
|
29
|
-
health: {
|
|
30
|
-
healthy: true,
|
|
31
|
-
},
|
|
32
|
-
}
|
|
33
|
-
: {
|
|
34
|
-
displayName: DISPLAY_NAME,
|
|
35
|
-
health: {
|
|
36
|
-
healthy: false,
|
|
37
|
-
message: MISSING_NODE_ENV_MESSAGE,
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
exports.default = addEnvChecker;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { ApplicationContract } from '@ioc:Adonis/Core/Application';
|
|
2
|
-
import { Checker, HealthReport, HealthCheckContract } from '@ioc:Adonis/Core/HealthCheck';
|
|
3
|
-
/**
|
|
4
|
-
* The module exposes the API to find the health, liveliness and readiness of
|
|
5
|
-
* the system. You can also add your own checkers.
|
|
6
|
-
*/
|
|
7
|
-
export declare class HealthCheck implements HealthCheckContract {
|
|
8
|
-
private application;
|
|
9
|
-
/**
|
|
10
|
-
* A copy of registered checkers
|
|
11
|
-
*/
|
|
12
|
-
private healthCheckers;
|
|
13
|
-
/**
|
|
14
|
-
* Reference to the IoC container to resolve health checkers
|
|
15
|
-
*/
|
|
16
|
-
private resolver;
|
|
17
|
-
/**
|
|
18
|
-
* Returns an array of registered services names
|
|
19
|
-
*/
|
|
20
|
-
get servicesList(): string[];
|
|
21
|
-
constructor(application: ApplicationContract);
|
|
22
|
-
/**
|
|
23
|
-
* Invokes a given checker to collect the report metrics.
|
|
24
|
-
*/
|
|
25
|
-
private invokeChecker;
|
|
26
|
-
/**
|
|
27
|
-
* A boolean to know, if all health checks have passed
|
|
28
|
-
* or not.
|
|
29
|
-
*/
|
|
30
|
-
isLive(): Promise<boolean>;
|
|
31
|
-
/**
|
|
32
|
-
* Add a custom checker to check a given service connectivity
|
|
33
|
-
* with the server
|
|
34
|
-
*/
|
|
35
|
-
addChecker(service: string, checker: Checker): void;
|
|
36
|
-
/**
|
|
37
|
-
* Ensure that application is ready. This relies on the application module.
|
|
38
|
-
*/
|
|
39
|
-
isReady(): boolean;
|
|
40
|
-
/**
|
|
41
|
-
* Returns the health check reports. The health checks are performed when
|
|
42
|
-
* this method is invoked.
|
|
43
|
-
*/
|
|
44
|
-
getReport(): Promise<{
|
|
45
|
-
healthy: boolean;
|
|
46
|
-
report: HealthReport;
|
|
47
|
-
}>;
|
|
48
|
-
}
|
|
@@ -1,99 +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.HealthCheck = void 0;
|
|
12
|
-
/**
|
|
13
|
-
* The module exposes the API to find the health, liveliness and readiness of
|
|
14
|
-
* the system. You can also add your own checkers.
|
|
15
|
-
*/
|
|
16
|
-
class HealthCheck {
|
|
17
|
-
/**
|
|
18
|
-
* Returns an array of registered services names
|
|
19
|
-
*/
|
|
20
|
-
get servicesList() {
|
|
21
|
-
return Object.keys(this.healthCheckers);
|
|
22
|
-
}
|
|
23
|
-
constructor(application) {
|
|
24
|
-
this.application = application;
|
|
25
|
-
/**
|
|
26
|
-
* A copy of registered checkers
|
|
27
|
-
*/
|
|
28
|
-
this.healthCheckers = {};
|
|
29
|
-
/**
|
|
30
|
-
* Reference to the IoC container to resolve health checkers
|
|
31
|
-
*/
|
|
32
|
-
this.resolver = this.application.container.getResolver('report');
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Invokes a given checker to collect the report metrics.
|
|
36
|
-
*/
|
|
37
|
-
async invokeChecker(service, reportSheet) {
|
|
38
|
-
const checker = this.healthCheckers[service];
|
|
39
|
-
let report;
|
|
40
|
-
try {
|
|
41
|
-
if (typeof checker === 'function') {
|
|
42
|
-
report = await checker();
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
report = await this.resolver.call(checker);
|
|
46
|
-
}
|
|
47
|
-
report.displayName = report.displayName || service;
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
report = {
|
|
51
|
-
displayName: service,
|
|
52
|
-
health: { healthy: false, message: error.message },
|
|
53
|
-
meta: { fatal: true },
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
reportSheet[service] = report;
|
|
57
|
-
return report.health.healthy;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* A boolean to know, if all health checks have passed
|
|
61
|
-
* or not.
|
|
62
|
-
*/
|
|
63
|
-
async isLive() {
|
|
64
|
-
if (!this.isReady()) {
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
const { healthy } = await this.getReport();
|
|
68
|
-
return healthy;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Add a custom checker to check a given service connectivity
|
|
72
|
-
* with the server
|
|
73
|
-
*/
|
|
74
|
-
addChecker(service, checker) {
|
|
75
|
-
this.healthCheckers[service] = checker;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Ensure that application is ready. This relies on the application module.
|
|
79
|
-
*/
|
|
80
|
-
isReady() {
|
|
81
|
-
return this.application.isReady;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Returns the health check reports. The health checks are performed when
|
|
85
|
-
* this method is invoked.
|
|
86
|
-
*/
|
|
87
|
-
async getReport() {
|
|
88
|
-
const report = {};
|
|
89
|
-
await Promise.all(Object.keys(this.healthCheckers).map((service) => {
|
|
90
|
-
return this.invokeChecker(service, report);
|
|
91
|
-
}));
|
|
92
|
-
/**
|
|
93
|
-
* Finding unhealthy service to know if system is healthy or not
|
|
94
|
-
*/
|
|
95
|
-
const unhealthyService = Object.keys(report).find((service) => !report[service].health.healthy);
|
|
96
|
-
return { healthy: !unhealthyService, report };
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
exports.HealthCheck = HealthCheck;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/// <reference types="@adonisjs/http-server/build/adonis-typings" />
|
|
2
|
-
import { CorsConfig } from '@ioc:Adonis/Core/Cors';
|
|
3
|
-
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
|
|
4
|
-
/**
|
|
5
|
-
* The Cors middleware class to handle preflight request as per the CORS
|
|
6
|
-
* RFC https://www.w3.org/TR/cors/.
|
|
7
|
-
*
|
|
8
|
-
* This is a functional middleware and shared among all requests. So make
|
|
9
|
-
* sure not to set request specific instance properties.
|
|
10
|
-
*/
|
|
11
|
-
export declare class Cors {
|
|
12
|
-
private options;
|
|
13
|
-
private isEnabled;
|
|
14
|
-
constructor(options: CorsConfig);
|
|
15
|
-
/**
|
|
16
|
-
* Normalize config options
|
|
17
|
-
*/
|
|
18
|
-
private normalizeOptions;
|
|
19
|
-
/**
|
|
20
|
-
* Computes the origin for the current request based upon the
|
|
21
|
-
* user config.
|
|
22
|
-
*
|
|
23
|
-
* Origin match is always case sensitive
|
|
24
|
-
*/
|
|
25
|
-
private computeResponseOrigin;
|
|
26
|
-
/**
|
|
27
|
-
* Returns an array of headers allowed based upon user config
|
|
28
|
-
* and request headers.
|
|
29
|
-
*
|
|
30
|
-
* The array items are casted to lowercase for case insensitive
|
|
31
|
-
* match.
|
|
32
|
-
*/
|
|
33
|
-
private computedAllowedHeaders;
|
|
34
|
-
/**
|
|
35
|
-
* Sets the `Access-Control-Allow-Origin` header
|
|
36
|
-
*/
|
|
37
|
-
private setOrigin;
|
|
38
|
-
/**
|
|
39
|
-
* Setting `Access-Control-Expose-Headers` headers, when custom headers
|
|
40
|
-
* are defined. If no custom headers are defined, then simple response
|
|
41
|
-
* headers are used instead.
|
|
42
|
-
*/
|
|
43
|
-
private setExposedHeaders;
|
|
44
|
-
/**
|
|
45
|
-
* Allows `Access-Control-Allow-Credentials` when enabled inside the user
|
|
46
|
-
* config.
|
|
47
|
-
*/
|
|
48
|
-
private setCredentials;
|
|
49
|
-
/**
|
|
50
|
-
* Set `Access-Control-Allow-Methods` header.
|
|
51
|
-
*/
|
|
52
|
-
private setAllowMethods;
|
|
53
|
-
/**
|
|
54
|
-
* Set `Access-Control-Allow-Headers` header.
|
|
55
|
-
*/
|
|
56
|
-
private setAllowHeaders;
|
|
57
|
-
/**
|
|
58
|
-
* Set `Access-Control-Max-Age` header.
|
|
59
|
-
*/
|
|
60
|
-
private setMaxAge;
|
|
61
|
-
/**
|
|
62
|
-
* Ends the preflight request with 204 status code
|
|
63
|
-
*/
|
|
64
|
-
private endPreFlight;
|
|
65
|
-
/**
|
|
66
|
-
* Handle HTTP request for CORS. This method is binded as a before hook
|
|
67
|
-
* to the HTTP server.
|
|
68
|
-
*/
|
|
69
|
-
handle(ctx: HttpContextContract): Promise<void>;
|
|
70
|
-
}
|