@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,12 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* file that was distributed with this source code.
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
const base_1 = require("./base");
|
|
12
|
-
exports.default = (0, base_1.getApp)().container.resolveBinding('Adonis/Core/Encryption');
|
|
1
|
+
import app from './app.js';
|
|
2
|
+
import { Encryption } from '../modules/encryption.js';
|
|
3
|
+
let encryption;
|
|
4
|
+
await app.booted(async () => {
|
|
5
|
+
encryption = await app.container.make(Encryption);
|
|
6
|
+
});
|
|
7
|
+
export { encryption as default };
|
package/build/services/hash.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
declare
|
|
3
|
-
export default
|
|
1
|
+
import type { HashService } from '../src/types.js';
|
|
2
|
+
declare let hash: HashService;
|
|
3
|
+
export { hash as default };
|
package/build/services/hash.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* file that was distributed with this source code.
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
const base_1 = require("./base");
|
|
12
|
-
exports.default = (0, base_1.getApp)().container.resolveBinding('Adonis/Core/Hash');
|
|
1
|
+
import app from './app.js';
|
|
2
|
+
import { HashManager } from '../modules/hash/main.js';
|
|
3
|
+
let hash;
|
|
4
|
+
await app.booted(async () => {
|
|
5
|
+
hash = await app.container.make(HashManager);
|
|
6
|
+
});
|
|
7
|
+
export { hash as default };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { EncodeOptions } from 'he';
|
|
2
|
+
import string from '@poppinss/utils/string';
|
|
3
|
+
declare const stringHelpers: typeof string & {
|
|
4
|
+
ordinalize: (typeof string)['ordinal'];
|
|
5
|
+
toSentence: (typeof string)['sentence'];
|
|
6
|
+
generateRandom: (typeof string)['random'];
|
|
7
|
+
prettyHrTime(time: [number, number], options?: {
|
|
8
|
+
verbose?: boolean | undefined;
|
|
9
|
+
precise?: boolean | undefined;
|
|
10
|
+
}): string;
|
|
11
|
+
isEmpty(value: string): boolean;
|
|
12
|
+
escapeHTML(value: string, options?: {
|
|
13
|
+
encodeSymbols?: boolean;
|
|
14
|
+
}): string;
|
|
15
|
+
encodeSymbols(value: string, options?: EncodeOptions): string;
|
|
16
|
+
};
|
|
17
|
+
export default stringHelpers;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import he from 'he';
|
|
2
|
+
import prettyHrTime from 'pretty-hrtime';
|
|
3
|
+
import string from '@poppinss/utils/string';
|
|
4
|
+
const stringHelpers = {
|
|
5
|
+
...string,
|
|
6
|
+
toSentence: string.sentence,
|
|
7
|
+
ordinalize: string.ordinal,
|
|
8
|
+
generateRandom: string.random,
|
|
9
|
+
prettyHrTime(time, options) {
|
|
10
|
+
return prettyHrTime(time, options);
|
|
11
|
+
},
|
|
12
|
+
isEmpty(value) {
|
|
13
|
+
return value.trim().length === 0;
|
|
14
|
+
},
|
|
15
|
+
escapeHTML(value, options) {
|
|
16
|
+
value = he.escape(value);
|
|
17
|
+
if (options && options.encodeSymbols) {
|
|
18
|
+
value = this.encodeSymbols(value, { allowUnsafeSymbols: true });
|
|
19
|
+
}
|
|
20
|
+
return value;
|
|
21
|
+
},
|
|
22
|
+
encodeSymbols(value, options) {
|
|
23
|
+
return he.encode(value, options);
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
export default stringHelpers;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare class StringBuilder {
|
|
2
|
+
#private;
|
|
3
|
+
constructor(value: string | StringBuilder);
|
|
4
|
+
dashCase(): this;
|
|
5
|
+
dotCase(): this;
|
|
6
|
+
snakeCase(): this;
|
|
7
|
+
pascalCase(): this;
|
|
8
|
+
camelCase(): this;
|
|
9
|
+
capitalCase(): this;
|
|
10
|
+
titleCase(): this;
|
|
11
|
+
sentenceCase(): this;
|
|
12
|
+
noCase(): this;
|
|
13
|
+
plural(): this;
|
|
14
|
+
singular(): this;
|
|
15
|
+
slugify(): this;
|
|
16
|
+
removeSuffix(suffix: string): this;
|
|
17
|
+
suffix(suffix: string): this;
|
|
18
|
+
removePrefix(prefix: string): this;
|
|
19
|
+
prefix(prefix: string): this;
|
|
20
|
+
removeExtension(): this;
|
|
21
|
+
ext(extension: string): this;
|
|
22
|
+
toString(): string;
|
|
23
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { extname } from 'node:path';
|
|
2
|
+
import string from './string.js';
|
|
3
|
+
export class StringBuilder {
|
|
4
|
+
#value;
|
|
5
|
+
constructor(value) {
|
|
6
|
+
this.#value = typeof value === 'string' ? value : value.toString();
|
|
7
|
+
}
|
|
8
|
+
dashCase() {
|
|
9
|
+
this.#value = string.dashCase(this.#value);
|
|
10
|
+
return this;
|
|
11
|
+
}
|
|
12
|
+
dotCase() {
|
|
13
|
+
this.#value = string.dotCase(this.#value);
|
|
14
|
+
return this;
|
|
15
|
+
}
|
|
16
|
+
snakeCase() {
|
|
17
|
+
this.#value = string.snakeCase(this.#value);
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
pascalCase() {
|
|
21
|
+
this.#value = string.pascalCase(this.#value);
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
camelCase() {
|
|
25
|
+
this.#value = string.camelCase(this.#value);
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
capitalCase() {
|
|
29
|
+
this.#value = string.capitalCase(this.#value);
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
titleCase() {
|
|
33
|
+
this.#value = string.titleCase(this.#value);
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
sentenceCase() {
|
|
37
|
+
this.#value = string.sentenceCase(this.#value);
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
noCase() {
|
|
41
|
+
this.#value = string.noCase(this.#value);
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
plural() {
|
|
45
|
+
this.#value = string.pluralize(this.#value);
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
singular() {
|
|
49
|
+
this.#value = string.singular(this.#value);
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
slugify() {
|
|
53
|
+
this.#value = string.slug(this.#value);
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
removeSuffix(suffix) {
|
|
57
|
+
this.#value = this.#value.replace(new RegExp(`[-_]?${suffix}$`, 'i'), '');
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
suffix(suffix) {
|
|
61
|
+
this.removeSuffix(suffix);
|
|
62
|
+
this.#value = `${this.#value}${suffix}`;
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
removePrefix(prefix) {
|
|
66
|
+
this.#value = this.#value.replace(new RegExp(`^${prefix}[-_]?`, 'i'), '');
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
prefix(prefix) {
|
|
70
|
+
this.removePrefix(prefix);
|
|
71
|
+
this.#value = `${prefix}${this.#value}`;
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
removeExtension() {
|
|
75
|
+
this.#value = this.#value.replace(new RegExp(`${extname(this.#value)}$`), '');
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
78
|
+
ext(extension) {
|
|
79
|
+
this.removeExtension();
|
|
80
|
+
this.#value = `${this.#value}.${extension.replace(/^\./, '')}`;
|
|
81
|
+
return this;
|
|
82
|
+
}
|
|
83
|
+
toString() {
|
|
84
|
+
return this.#value;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import is from '@sindresorhus/is';
|
|
3
|
+
declare const types: {
|
|
4
|
+
lookup: typeof is;
|
|
5
|
+
isNull: (value: unknown) => value is null;
|
|
6
|
+
isBoolean: (value: unknown) => value is boolean;
|
|
7
|
+
isBuffer: (value: unknown) => value is Buffer;
|
|
8
|
+
isNumber: (value: unknown) => value is number;
|
|
9
|
+
isString: (value: unknown) => value is string;
|
|
10
|
+
isArguments: any;
|
|
11
|
+
isObject: (value: unknown) => value is object;
|
|
12
|
+
isDate: (value: unknown) => value is Date;
|
|
13
|
+
isArray: <T = unknown>(value: unknown, assertion?: ((value: T) => value is T) | undefined) => value is T[];
|
|
14
|
+
isRegexp: (value: unknown) => value is RegExp;
|
|
15
|
+
isError: (value: unknown) => value is Error;
|
|
16
|
+
isFunction: (value: unknown) => value is Function;
|
|
17
|
+
isClass: (value: unknown) => value is import("@sindresorhus/is").Class<unknown, any[]>;
|
|
18
|
+
isInteger: (value: unknown) => value is number;
|
|
19
|
+
isFloat(value: number): value is number;
|
|
20
|
+
isDecimal(value: string | number, options?: {
|
|
21
|
+
decimalPlaces?: string;
|
|
22
|
+
}): boolean;
|
|
23
|
+
};
|
|
24
|
+
export default types;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import is from '@sindresorhus/is';
|
|
2
|
+
const types = {
|
|
3
|
+
lookup: is,
|
|
4
|
+
isNull: is.null_,
|
|
5
|
+
isBoolean: is.boolean,
|
|
6
|
+
isBuffer: is.buffer,
|
|
7
|
+
isNumber: is.number,
|
|
8
|
+
isString: is.string,
|
|
9
|
+
isArguments: is.arguments,
|
|
10
|
+
isObject: is.object,
|
|
11
|
+
isDate: is.date,
|
|
12
|
+
isArray: is.array,
|
|
13
|
+
isRegexp: is.regExp,
|
|
14
|
+
isError: is.error,
|
|
15
|
+
isFunction: is.function_,
|
|
16
|
+
isClass: is.class_,
|
|
17
|
+
isInteger: is.integer,
|
|
18
|
+
isFloat(value) {
|
|
19
|
+
return value !== (value | 0);
|
|
20
|
+
},
|
|
21
|
+
isDecimal(value, options) {
|
|
22
|
+
if (typeof value === 'number') {
|
|
23
|
+
value = value.toString();
|
|
24
|
+
}
|
|
25
|
+
const decimalPlaces = (options && options.decimalPlaces) || '1,';
|
|
26
|
+
return new RegExp(`^[-+]?([0-9]+)?(\\.[0-9]{${decimalPlaces}})$`).test(value);
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
export default types;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Ignitor } from './main.js';
|
|
2
|
+
import type { ApplicationService } from '../types.js';
|
|
3
|
+
export declare class AceProcess {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(ignitor: Ignitor);
|
|
6
|
+
configure(callback: (app: ApplicationService) => Promise<void> | void): this;
|
|
7
|
+
handle(argv: string[]): Promise<void>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export class AceProcess {
|
|
2
|
+
#ignitor;
|
|
3
|
+
#configureCallback = () => { };
|
|
4
|
+
constructor(ignitor) {
|
|
5
|
+
this.#ignitor = ignitor;
|
|
6
|
+
}
|
|
7
|
+
configure(callback) {
|
|
8
|
+
this.#configureCallback = callback;
|
|
9
|
+
return this;
|
|
10
|
+
}
|
|
11
|
+
async handle(argv) {
|
|
12
|
+
const app = this.#ignitor.createApp('console');
|
|
13
|
+
await app.init();
|
|
14
|
+
const { createAceKernel } = await import('../../modules/ace/create_kernel.js');
|
|
15
|
+
const kernel = createAceKernel(app);
|
|
16
|
+
app.container.bindValue('ace', kernel);
|
|
17
|
+
kernel.loading(async (metaData) => {
|
|
18
|
+
if (metaData.options.startApp && !app.isReady) {
|
|
19
|
+
await app.boot();
|
|
20
|
+
await app.start(() => { });
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
await this.#configureCallback(app);
|
|
24
|
+
await kernel.handle(argv);
|
|
25
|
+
process.exitCode = kernel.exitCode;
|
|
26
|
+
const mainCommand = kernel.getMainCommand();
|
|
27
|
+
if (!mainCommand || !mainCommand.staysAlive) {
|
|
28
|
+
await app.terminate();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
import type { Server as NodeHttpsServer } from 'node:https';
|
|
4
|
+
import { IncomingMessage, ServerResponse, Server as NodeHttpServer } from 'node:http';
|
|
5
|
+
import { Ignitor } from './main.js';
|
|
6
|
+
export declare class HttpServerProcess {
|
|
7
|
+
#private;
|
|
8
|
+
constructor(ignitor: Ignitor);
|
|
9
|
+
start(serverCallback?: (handler: (req: IncomingMessage, res: ServerResponse) => any) => NodeHttpsServer | NodeHttpServer): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { createServer } from 'node:http';
|
|
2
|
+
import debug from '../debug.js';
|
|
3
|
+
export class HttpServerProcess {
|
|
4
|
+
#ignitor;
|
|
5
|
+
constructor(ignitor) {
|
|
6
|
+
this.#ignitor = ignitor;
|
|
7
|
+
}
|
|
8
|
+
#close(nodeHttpServer) {
|
|
9
|
+
return new Promise((resolve) => {
|
|
10
|
+
debug('closing http server process');
|
|
11
|
+
nodeHttpServer.close(() => resolve());
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
#monitorAppAndServer(nodeHttpServer, app, logger) {
|
|
15
|
+
app.terminating(async () => {
|
|
16
|
+
debug('terminating signal received');
|
|
17
|
+
await this.#close(nodeHttpServer);
|
|
18
|
+
});
|
|
19
|
+
nodeHttpServer.once('error', (error) => {
|
|
20
|
+
debug('http server crashed with error "%O"', error);
|
|
21
|
+
logger.fatal({ err: error }, error.message);
|
|
22
|
+
process.exitCode = 1;
|
|
23
|
+
app.terminate();
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
#listen(nodeHttpServer) {
|
|
27
|
+
return new Promise((resolve, reject) => {
|
|
28
|
+
const host = process.env.HOST || '0.0.0.0';
|
|
29
|
+
const port = Number(process.env.PORT || '3333');
|
|
30
|
+
nodeHttpServer.listen(port, host);
|
|
31
|
+
nodeHttpServer.once('listening', () => {
|
|
32
|
+
debug('listening to http server, host :%s, port: %s', host, port);
|
|
33
|
+
resolve({ port, host });
|
|
34
|
+
});
|
|
35
|
+
nodeHttpServer.once('error', (error) => {
|
|
36
|
+
reject(error);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
#notifyServerHasStarted(app, logger, emitter, payload) {
|
|
41
|
+
app.notify({ isAdonisJS: true, environment: 'web', ...payload });
|
|
42
|
+
logger.info('started HTTP server on %s:%s', payload.host, payload.port);
|
|
43
|
+
emitter.emit('http:server_ready', payload);
|
|
44
|
+
}
|
|
45
|
+
async start(serverCallback) {
|
|
46
|
+
const createHTTPServer = serverCallback || createServer;
|
|
47
|
+
const app = this.#ignitor.createApp('web');
|
|
48
|
+
await app.init();
|
|
49
|
+
await app.boot();
|
|
50
|
+
await app.start(async () => {
|
|
51
|
+
const server = await app.container.make('server');
|
|
52
|
+
await server.boot();
|
|
53
|
+
const httpServer = createHTTPServer(server.handle.bind(server));
|
|
54
|
+
server.setNodeServer(httpServer);
|
|
55
|
+
const logger = await app.container.make('logger');
|
|
56
|
+
const emitter = await app.container.make('emitter');
|
|
57
|
+
const payload = await this.#listen(httpServer);
|
|
58
|
+
this.#notifyServerHasStarted(app, logger, emitter, payload);
|
|
59
|
+
this.#monitorAppAndServer(httpServer, app, logger);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import { AceProcess } from './ace.js';
|
|
3
|
+
import { TestRunnerProcess } from './test.js';
|
|
4
|
+
import { HttpServerProcess } from './http.js';
|
|
5
|
+
import type { AppEnvironments } from '../../types/app.js';
|
|
6
|
+
import type { ApplicationService, IgnitorOptions } from '../types.js';
|
|
7
|
+
export declare class Ignitor {
|
|
8
|
+
#private;
|
|
9
|
+
constructor(appRoot: URL, options: IgnitorOptions);
|
|
10
|
+
getApp(): ApplicationService | undefined;
|
|
11
|
+
createApp(environment: AppEnvironments): ApplicationService;
|
|
12
|
+
tap(callback: (app: ApplicationService) => void): this;
|
|
13
|
+
httpServer(): HttpServerProcess;
|
|
14
|
+
ace(): AceProcess;
|
|
15
|
+
testRunner(): TestRunnerProcess;
|
|
16
|
+
terminate(): Promise<void>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import debug from '../debug.js';
|
|
2
|
+
import { AceProcess } from './ace.js';
|
|
3
|
+
import { TestRunnerProcess } from './test.js';
|
|
4
|
+
import { HttpServerProcess } from './http.js';
|
|
5
|
+
import { setApp } from '../../services/app.js';
|
|
6
|
+
import { Application } from '../../modules/app.js';
|
|
7
|
+
export class Ignitor {
|
|
8
|
+
#options;
|
|
9
|
+
#appRoot;
|
|
10
|
+
#app;
|
|
11
|
+
#tapCallbacks = new Set();
|
|
12
|
+
constructor(appRoot, options) {
|
|
13
|
+
this.#appRoot = appRoot;
|
|
14
|
+
this.#options = options;
|
|
15
|
+
}
|
|
16
|
+
#runTapCallbacks(app) {
|
|
17
|
+
this.#tapCallbacks.forEach((tapCallback) => tapCallback(app));
|
|
18
|
+
}
|
|
19
|
+
getApp() {
|
|
20
|
+
return this.#app;
|
|
21
|
+
}
|
|
22
|
+
createApp(environment) {
|
|
23
|
+
debug('creating application instance');
|
|
24
|
+
this.#app = new Application(this.#appRoot, { environment, importer: this.#options.importer });
|
|
25
|
+
setApp(this.#app);
|
|
26
|
+
this.#runTapCallbacks(this.#app);
|
|
27
|
+
return this.#app;
|
|
28
|
+
}
|
|
29
|
+
tap(callback) {
|
|
30
|
+
this.#tapCallbacks.add(callback);
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
httpServer() {
|
|
34
|
+
return new HttpServerProcess(this);
|
|
35
|
+
}
|
|
36
|
+
ace() {
|
|
37
|
+
return new AceProcess(this);
|
|
38
|
+
}
|
|
39
|
+
testRunner() {
|
|
40
|
+
return new TestRunnerProcess(this);
|
|
41
|
+
}
|
|
42
|
+
async terminate() {
|
|
43
|
+
await this.#app?.terminate();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Ignitor } from './main.js';
|
|
2
|
+
import type { ApplicationService } from '../types.js';
|
|
3
|
+
export declare class TestRunnerProcess {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(ignitor: Ignitor);
|
|
6
|
+
configure(callback: (app: ApplicationService) => Promise<void> | void): this;
|
|
7
|
+
run(callback: (app: ApplicationService) => Promise<void> | void): Promise<void>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export class TestRunnerProcess {
|
|
2
|
+
#ignitor;
|
|
3
|
+
#configureCallback = () => { };
|
|
4
|
+
constructor(ignitor) {
|
|
5
|
+
this.#ignitor = ignitor;
|
|
6
|
+
}
|
|
7
|
+
configure(callback) {
|
|
8
|
+
this.#configureCallback = callback;
|
|
9
|
+
return this;
|
|
10
|
+
}
|
|
11
|
+
async run(callback) {
|
|
12
|
+
const app = this.#ignitor.createApp('test');
|
|
13
|
+
await app.init();
|
|
14
|
+
await app.boot();
|
|
15
|
+
await app.start(this.#configureCallback);
|
|
16
|
+
await callback(app);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
import type { TestUtils } from './main.js';
|
|
4
|
+
import type { Server as NodeHttpsServer } from 'node:https';
|
|
5
|
+
import { IncomingMessage, ServerResponse, Server as NodeHttpServer } from 'node:http';
|
|
6
|
+
export declare class HttpServerUtils {
|
|
7
|
+
#private;
|
|
8
|
+
constructor(utils: TestUtils);
|
|
9
|
+
start(serverCallback?: (handler: (req: IncomingMessage, res: ServerResponse) => any) => NodeHttpsServer | NodeHttpServer): Promise<() => Promise<void>>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import debug from '../debug.js';
|
|
2
|
+
import { createServer } from 'node:http';
|
|
3
|
+
export class HttpServerUtils {
|
|
4
|
+
#utils;
|
|
5
|
+
constructor(utils) {
|
|
6
|
+
this.#utils = utils;
|
|
7
|
+
}
|
|
8
|
+
#listen(nodeHttpServer) {
|
|
9
|
+
return new Promise((resolve, reject) => {
|
|
10
|
+
const host = process.env.HOST || '0.0.0.0';
|
|
11
|
+
const port = Number(process.env.PORT || '3333');
|
|
12
|
+
nodeHttpServer.listen(port, host);
|
|
13
|
+
nodeHttpServer.once('listening', () => {
|
|
14
|
+
debug('listening to utils http server, host :%s, port: %s', host, port);
|
|
15
|
+
resolve({ port, host });
|
|
16
|
+
});
|
|
17
|
+
nodeHttpServer.once('error', (error) => {
|
|
18
|
+
reject(error);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
async start(serverCallback) {
|
|
23
|
+
const createHTTPServer = serverCallback || createServer;
|
|
24
|
+
const server = await this.#utils.app.container.make('server');
|
|
25
|
+
await server.boot();
|
|
26
|
+
const httpServer = createHTTPServer(server.handle.bind(server));
|
|
27
|
+
server.setNodeServer(httpServer);
|
|
28
|
+
await this.#listen(httpServer);
|
|
29
|
+
return () => {
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
httpServer.close((error) => {
|
|
32
|
+
if (error) {
|
|
33
|
+
reject(error);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
resolve();
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import Macroable from '@poppinss/macroable';
|
|
3
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
4
|
+
import { HttpServerUtils } from './http.js';
|
|
5
|
+
import type { ApplicationService } from '../types.js';
|
|
6
|
+
import { CookieClient } from '../../modules/http.js';
|
|
7
|
+
export declare class TestUtils extends Macroable {
|
|
8
|
+
#private;
|
|
9
|
+
app: ApplicationService;
|
|
10
|
+
get isBooted(): boolean;
|
|
11
|
+
cookies: CookieClient;
|
|
12
|
+
constructor(app: ApplicationService);
|
|
13
|
+
boot(): Promise<void>;
|
|
14
|
+
httpServer(): HttpServerUtils;
|
|
15
|
+
createHttpContext(options?: {
|
|
16
|
+
req?: IncomingMessage;
|
|
17
|
+
res?: ServerResponse;
|
|
18
|
+
}): Promise<import("../../modules/http.js").HttpContext>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Socket } from 'node:net';
|
|
2
|
+
import Macroable from '@poppinss/macroable';
|
|
3
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
4
|
+
import { HttpServerUtils } from './http.js';
|
|
5
|
+
import { CookieClient } from '../../modules/http.js';
|
|
6
|
+
export class TestUtils extends Macroable {
|
|
7
|
+
app;
|
|
8
|
+
#booted = false;
|
|
9
|
+
get isBooted() {
|
|
10
|
+
return this.#booted;
|
|
11
|
+
}
|
|
12
|
+
constructor(app) {
|
|
13
|
+
super();
|
|
14
|
+
this.app = app;
|
|
15
|
+
}
|
|
16
|
+
async boot() {
|
|
17
|
+
if (!this.isBooted) {
|
|
18
|
+
this.#booted = true;
|
|
19
|
+
this.cookies = new CookieClient(await this.app.container.make('encryption'));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
httpServer() {
|
|
23
|
+
return new HttpServerUtils(this);
|
|
24
|
+
}
|
|
25
|
+
async createHttpContext(options = {}) {
|
|
26
|
+
const req = options.req || new IncomingMessage(new Socket());
|
|
27
|
+
const res = options.res || new ServerResponse(req);
|
|
28
|
+
const server = await this.app.container.make('server');
|
|
29
|
+
const request = server.createRequest(req, res);
|
|
30
|
+
const response = server.createResponse(req, res);
|
|
31
|
+
return server.createHttpContext(request, response, this.app.container.createResolver());
|
|
32
|
+
}
|
|
33
|
+
}
|