@adonisjs/core 6.18.0 → 7.0.0-next.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/build/commands/add.d.ts +4 -5
- package/build/commands/add.js +7 -60
- package/build/commands/build.d.ts +1 -3
- package/build/commands/build.js +4 -36
- package/build/commands/commands.json +1 -1
- package/build/commands/configure.d.ts +3 -3
- package/build/commands/configure.js +3 -3
- package/build/commands/eject.d.ts +1 -1
- package/build/commands/eject.js +3 -3
- package/build/commands/env/add.d.ts +2 -2
- package/build/commands/env/add.js +2 -2
- package/build/commands/generate_key.d.ts +1 -1
- package/build/commands/generate_key.js +1 -1
- package/build/commands/inspect_rcfile.d.ts +1 -1
- package/build/commands/inspect_rcfile.js +1 -1
- package/build/commands/list/routes.d.ts +2 -2
- package/build/commands/list/routes.js +2 -2
- package/build/commands/make/command.d.ts +1 -1
- package/build/commands/make/command.js +3 -3
- package/build/commands/make/controller.d.ts +2 -2
- package/build/commands/make/controller.js +2 -2
- package/build/commands/make/event.d.ts +2 -2
- package/build/commands/make/event.js +2 -2
- package/build/commands/make/exception.d.ts +2 -2
- package/build/commands/make/exception.js +2 -2
- package/build/commands/make/listener.d.ts +2 -2
- package/build/commands/make/listener.js +2 -2
- package/build/commands/make/middleware.d.ts +2 -2
- package/build/commands/make/middleware.js +4 -4
- package/build/commands/make/preload.d.ts +1 -1
- package/build/commands/make/preload.js +4 -4
- package/build/commands/make/provider.d.ts +1 -1
- package/build/commands/make/provider.js +4 -4
- package/build/commands/make/service.d.ts +2 -2
- package/build/commands/make/service.js +2 -2
- package/build/commands/make/test.d.ts +1 -1
- package/build/commands/make/test.js +2 -2
- package/build/commands/make/validator.d.ts +2 -2
- package/build/commands/make/validator.js +2 -2
- package/build/commands/make/view.d.ts +1 -1
- package/build/commands/make/view.js +2 -2
- package/build/commands/repl.d.ts +2 -2
- package/build/commands/repl.js +1 -1
- package/build/commands/serve.d.ts +2 -4
- package/build/commands/serve.js +11 -43
- package/build/commands/test.d.ts +2 -4
- package/build/commands/test.js +4 -32
- package/build/factories/core/ace.d.ts +31 -4
- package/build/factories/core/ace.js +20 -4
- package/build/factories/core/ignitor.d.ts +80 -9
- package/build/factories/core/ignitor.js +84 -13
- package/build/factories/core/main.d.ts +3 -3
- package/build/factories/core/main.js +3 -3
- package/build/factories/core/test_utils.d.ts +32 -4
- package/build/factories/core/test_utils.js +21 -4
- package/build/factories/stubs.d.ts +54 -5
- package/build/factories/stubs.js +55 -6
- package/build/index.d.ts +5 -4
- package/build/index.js +13 -9
- package/build/modules/ace/codemods.d.ts +71 -11
- package/build/modules/ace/codemods.js +90 -22
- package/build/modules/ace/commands.d.ts +49 -13
- package/build/modules/ace/commands.js +48 -10
- package/build/modules/ace/create_kernel.d.ts +19 -8
- package/build/modules/ace/create_kernel.js +19 -8
- package/build/modules/ace/kernel.d.ts +18 -4
- package/build/modules/ace/kernel.js +17 -3
- package/build/modules/ace/main.d.ts +3 -3
- package/build/modules/ace/main.js +3 -3
- package/build/modules/dumper/define_config.d.ts +25 -4
- package/build/modules/dumper/define_config.js +23 -2
- package/build/modules/dumper/dumper.d.ts +82 -12
- package/build/modules/dumper/dumper.js +82 -12
- package/build/modules/dumper/errors.d.ts +31 -10
- package/build/modules/dumper/errors.js +28 -7
- package/build/modules/dumper/main.d.ts +3 -3
- package/build/modules/dumper/main.js +3 -3
- package/build/modules/dumper/plugins/edge.d.ts +1 -1
- package/build/modules/hash/define_config.d.ts +53 -8
- package/build/modules/hash/define_config.js +51 -6
- package/build/modules/hash/main.d.ts +1 -1
- package/build/modules/hash/main.js +1 -1
- package/build/modules/http/main.d.ts +1 -1
- package/build/modules/http/main.js +1 -1
- package/build/modules/http/request_validator.d.ts +36 -9
- package/build/modules/http/request_validator.js +32 -5
- package/build/modules/transformers/main.d.ts +1 -0
- package/build/modules/transformers/main.js +9 -0
- package/build/providers/app_provider.d.ts +173 -1
- package/build/providers/app_provider.js +204 -8
- package/build/providers/edge_provider.d.ts +31 -2
- package/build/providers/edge_provider.js +31 -2
- package/build/providers/hash_provider.d.ts +38 -1
- package/build/providers/hash_provider.js +40 -3
- package/build/providers/repl_provider.d.ts +40 -1
- package/build/providers/repl_provider.js +52 -2
- package/build/providers/vinejs_provider.d.ts +32 -23
- package/build/providers/vinejs_provider.js +32 -66
- package/build/services/ace.d.ts +1 -1
- package/build/services/ace.js +1 -1
- package/build/services/app.d.ts +1 -1
- package/build/services/config.d.ts +1 -1
- package/build/services/config.js +1 -1
- package/build/services/dumper.js +1 -1
- package/build/services/emitter.d.ts +1 -1
- package/build/services/emitter.js +1 -1
- package/build/services/encryption.d.ts +1 -1
- package/build/services/encryption.js +1 -1
- package/build/services/hash.d.ts +1 -1
- package/build/services/hash.js +1 -1
- package/build/services/logger.d.ts +1 -1
- package/build/services/logger.js +1 -1
- package/build/services/repl.d.ts +1 -1
- package/build/services/repl.js +1 -1
- package/build/services/router.d.ts +1 -1
- package/build/services/router.js +1 -1
- package/build/services/server.d.ts +1 -1
- package/build/services/server.js +1 -1
- package/build/services/test_utils.d.ts +1 -1
- package/build/services/test_utils.js +1 -1
- package/build/services/url_builder.d.ts +4 -0
- package/build/services/url_builder.js +21 -0
- package/build/src/assembler_hooks/index_entities.d.ts +51 -0
- package/build/src/assembler_hooks/index_entities.js +96 -0
- package/build/src/cli_formatters/routes_list.d.ts +24 -12
- package/build/src/cli_formatters/routes_list.js +43 -46
- package/build/src/config_provider.d.ts +48 -3
- package/build/src/config_provider.js +47 -2
- package/build/src/debug.d.ts +15 -0
- package/build/src/debug.js +15 -0
- package/build/src/exceptions.d.ts +41 -1
- package/build/src/exceptions.js +41 -1
- package/build/src/helpers/assert.d.ts +47 -1
- package/build/src/helpers/assert.js +47 -1
- package/build/src/helpers/is.d.ts +21 -0
- package/build/src/helpers/is.js +21 -0
- package/build/src/helpers/main.d.ts +48 -5
- package/build/src/helpers/main.js +48 -5
- package/build/src/helpers/string.d.ts +89 -9
- package/build/src/helpers/string.js +15 -2
- package/build/src/helpers/types.d.ts +96 -2
- package/build/src/helpers/types.js +96 -2
- package/build/src/helpers/verification_token.d.ts +22 -1
- package/build/src/helpers/verification_token.js +24 -2
- package/build/src/ignitor/ace.d.ts +23 -3
- package/build/src/ignitor/ace.js +21 -1
- package/build/src/ignitor/http.d.ts +16 -3
- package/build/src/ignitor/http.js +16 -3
- package/build/src/ignitor/main.d.ts +29 -6
- package/build/src/ignitor/main.js +30 -7
- package/build/src/ignitor/test.d.ts +26 -3
- package/build/src/ignitor/test.js +24 -1
- package/build/src/test_utils/http.d.ts +19 -3
- package/build/src/test_utils/http.js +24 -3
- package/build/src/test_utils/main.d.ts +22 -4
- package/build/src/test_utils/main.js +21 -3
- package/build/src/types.d.ts +277 -26
- package/build/src/utils.d.ts +34 -0
- package/build/src/utils.js +49 -0
- package/build/src/vine.d.ts +42 -0
- package/build/src/vine.js +97 -0
- package/build/stubs/main.js +1 -2
- package/build/toolkit/main.js +1 -1
- package/build/types/helpers.d.ts +2 -1
- package/build/types/transformers.d.ts +1 -0
- package/build/types/transformers.js +9 -0
- package/package.json +57 -55
- package/build/src/helpers/parse_binding_reference.d.ts +0 -45
- package/build/src/helpers/parse_binding_reference.js +0 -83
- package/build/src/internal_helpers.d.ts +0 -15
- package/build/src/internal_helpers.js +0 -63
package/build/services/server.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
import app from
|
|
9
|
+
import app from "./app.js";
|
|
10
10
|
let server;
|
|
11
11
|
/**
|
|
12
12
|
* Returns a singleton instance of the HTTP server
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
import app from
|
|
9
|
+
import app from "./app.js";
|
|
10
10
|
let testUtils;
|
|
11
11
|
/**
|
|
12
12
|
* Returns a singleton instance of the TestUtils class
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @adonisjs/core
|
|
3
|
+
*
|
|
4
|
+
* (c) AdonisJS
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
9
|
+
import app from "./app.js";
|
|
10
|
+
let urlFor;
|
|
11
|
+
let signedUrlFor;
|
|
12
|
+
/**
|
|
13
|
+
* Returns a singleton instance of the router class from
|
|
14
|
+
* the container
|
|
15
|
+
*/
|
|
16
|
+
await app.booted(async () => {
|
|
17
|
+
const router = await app.container.make('router');
|
|
18
|
+
urlFor = router.urlBuilder.urlFor;
|
|
19
|
+
signedUrlFor = router.urlBuilder.signedUrlFor;
|
|
20
|
+
});
|
|
21
|
+
export { urlFor, signedUrlFor };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type IndexEntitiesConfig } from '../types.ts';
|
|
2
|
+
import { type CommonHooks } from '@adonisjs/assembler/types';
|
|
3
|
+
/**
|
|
4
|
+
* Configures the IndexGenerator to create barrel files for "controllers", "events",
|
|
5
|
+
* and "listeners". This function is used as an assembler hook to automatically generate
|
|
6
|
+
* index files that export all modules from specified directories.
|
|
7
|
+
*
|
|
8
|
+
* @param {IndexEntitiesConfig} entities - Configuration object for entities indexing
|
|
9
|
+
* @param {object} [entities.events] - Configuration for events indexing
|
|
10
|
+
* @param {boolean} [entities.events.enabled=true] - Whether to enable events indexing
|
|
11
|
+
* @param {string} [entities.events.source='app/events'] - Source directory for events
|
|
12
|
+
* @param {string} [entities.events.importAlias='#events'] - Import alias for events
|
|
13
|
+
* @param {string} [entities.events.glob] - Glob pattern for matching event files
|
|
14
|
+
* @param {object} [entities.listeners] - Configuration for listeners indexing
|
|
15
|
+
* @param {boolean} [entities.listeners.enabled=true] - Whether to enable listeners indexing
|
|
16
|
+
* @param {string} [entities.listeners.source='app/listeners'] - Source directory for listeners
|
|
17
|
+
* @param {string} [entities.listeners.importAlias='#listeners'] - Import alias for listeners
|
|
18
|
+
* @param {string} [entities.listeners.glob] - Glob pattern for matching listener files
|
|
19
|
+
* @param {object} [entities.controllers] - Configuration for controllers indexing
|
|
20
|
+
* @param {boolean} [entities.controllers.enabled=true] - Whether to enable controllers indexing
|
|
21
|
+
* @param {string} [entities.controllers.source='app/controllers'] - Source directory for controllers
|
|
22
|
+
* @param {string} [entities.controllers.importAlias='#controllers'] - Import alias for controllers
|
|
23
|
+
* @param {string} [entities.controllers.glob] - Glob pattern for matching controller files
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // Basic usage with default configuration
|
|
27
|
+
* indexEntities({})
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* // Custom configuration for specific entities
|
|
31
|
+
* indexEntities({
|
|
32
|
+
* events: {
|
|
33
|
+
* enabled: true,
|
|
34
|
+
* source: 'app/custom-events',
|
|
35
|
+
* importAlias: '#custom-events'
|
|
36
|
+
* },
|
|
37
|
+
* controllers: {
|
|
38
|
+
* enabled: false
|
|
39
|
+
* }
|
|
40
|
+
* })
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* // Using custom glob patterns
|
|
44
|
+
* indexEntities({
|
|
45
|
+
* listeners: {
|
|
46
|
+
* source: 'app/handlers',
|
|
47
|
+
* glob: '**\/*_handler.ts'
|
|
48
|
+
* }
|
|
49
|
+
* })
|
|
50
|
+
*/
|
|
51
|
+
export declare function indexEntities(entities?: IndexEntitiesConfig): CommonHooks['init'][number];
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @adonisjs/core
|
|
3
|
+
*
|
|
4
|
+
* (c) AdonisJS
|
|
5
|
+
*
|
|
6
|
+
* For the full copyright and license information, please view the LICENSE
|
|
7
|
+
* file that was distributed with this source code.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Configures the IndexGenerator to create barrel files for "controllers", "events",
|
|
11
|
+
* and "listeners". This function is used as an assembler hook to automatically generate
|
|
12
|
+
* index files that export all modules from specified directories.
|
|
13
|
+
*
|
|
14
|
+
* @param {IndexEntitiesConfig} entities - Configuration object for entities indexing
|
|
15
|
+
* @param {object} [entities.events] - Configuration for events indexing
|
|
16
|
+
* @param {boolean} [entities.events.enabled=true] - Whether to enable events indexing
|
|
17
|
+
* @param {string} [entities.events.source='app/events'] - Source directory for events
|
|
18
|
+
* @param {string} [entities.events.importAlias='#events'] - Import alias for events
|
|
19
|
+
* @param {string} [entities.events.glob] - Glob pattern for matching event files
|
|
20
|
+
* @param {object} [entities.listeners] - Configuration for listeners indexing
|
|
21
|
+
* @param {boolean} [entities.listeners.enabled=true] - Whether to enable listeners indexing
|
|
22
|
+
* @param {string} [entities.listeners.source='app/listeners'] - Source directory for listeners
|
|
23
|
+
* @param {string} [entities.listeners.importAlias='#listeners'] - Import alias for listeners
|
|
24
|
+
* @param {string} [entities.listeners.glob] - Glob pattern for matching listener files
|
|
25
|
+
* @param {object} [entities.controllers] - Configuration for controllers indexing
|
|
26
|
+
* @param {boolean} [entities.controllers.enabled=true] - Whether to enable controllers indexing
|
|
27
|
+
* @param {string} [entities.controllers.source='app/controllers'] - Source directory for controllers
|
|
28
|
+
* @param {string} [entities.controllers.importAlias='#controllers'] - Import alias for controllers
|
|
29
|
+
* @param {string} [entities.controllers.glob] - Glob pattern for matching controller files
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* // Basic usage with default configuration
|
|
33
|
+
* indexEntities({})
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* // Custom configuration for specific entities
|
|
37
|
+
* indexEntities({
|
|
38
|
+
* events: {
|
|
39
|
+
* enabled: true,
|
|
40
|
+
* source: 'app/custom-events',
|
|
41
|
+
* importAlias: '#custom-events'
|
|
42
|
+
* },
|
|
43
|
+
* controllers: {
|
|
44
|
+
* enabled: false
|
|
45
|
+
* }
|
|
46
|
+
* })
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* // Using custom glob patterns
|
|
50
|
+
* indexEntities({
|
|
51
|
+
* listeners: {
|
|
52
|
+
* source: 'app/handlers',
|
|
53
|
+
* glob: '**\/*_handler.ts'
|
|
54
|
+
* }
|
|
55
|
+
* })
|
|
56
|
+
*/
|
|
57
|
+
export function indexEntities(entities = {}) {
|
|
58
|
+
const events = Object.assign({ enabled: true, source: 'app/events', importAlias: '#events' }, entities.events);
|
|
59
|
+
const listeners = Object.assign({ enabled: true, source: 'app/listeners', importAlias: '#listeners' }, entities.listeners);
|
|
60
|
+
const controllers = Object.assign({ enabled: true, source: 'app/controllers', importAlias: '#controllers' }, entities.controllers);
|
|
61
|
+
return {
|
|
62
|
+
run(_, indexGenerator) {
|
|
63
|
+
if (events.enabled) {
|
|
64
|
+
indexGenerator.add('events', {
|
|
65
|
+
source: events.source,
|
|
66
|
+
glob: events.glob,
|
|
67
|
+
as: 'barrelFile',
|
|
68
|
+
exportName: 'events',
|
|
69
|
+
importAlias: events.importAlias,
|
|
70
|
+
output: '.adonisjs/server/events.ts',
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
if (listeners.enabled) {
|
|
74
|
+
indexGenerator.add('listeners', {
|
|
75
|
+
source: listeners.source,
|
|
76
|
+
glob: listeners.glob,
|
|
77
|
+
as: 'barrelFile',
|
|
78
|
+
exportName: 'listeners',
|
|
79
|
+
importAlias: listeners.importAlias,
|
|
80
|
+
output: '.adonisjs/server/listeners.ts',
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
if (controllers.enabled) {
|
|
84
|
+
indexGenerator.add('controllers', {
|
|
85
|
+
source: controllers.source,
|
|
86
|
+
glob: controllers.glob,
|
|
87
|
+
as: 'barrelFile',
|
|
88
|
+
exportName: 'controllers',
|
|
89
|
+
importAlias: controllers.importAlias,
|
|
90
|
+
removeSuffix: 'controller',
|
|
91
|
+
output: '.adonisjs/server/controllers.ts',
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { UIPrimitives } from '../../types/ace.
|
|
2
|
-
import { type Router } from '../../modules/http/main.
|
|
1
|
+
import type { UIPrimitives } from '../../types/ace.ts';
|
|
2
|
+
import { type Router } from '../../modules/http/main.ts';
|
|
3
|
+
import type { MiddlewareHandlerInfo, RouteHandlerInfo } from '../../types/http.ts';
|
|
3
4
|
/**
|
|
4
5
|
* Shape of the serialized route specific to the formatter
|
|
5
6
|
*/
|
|
@@ -7,25 +8,36 @@ type SerializedRoute = {
|
|
|
7
8
|
name: string;
|
|
8
9
|
pattern: string;
|
|
9
10
|
methods: string[];
|
|
10
|
-
middleware:
|
|
11
|
-
handler:
|
|
12
|
-
type: 'closure';
|
|
13
|
-
name: string;
|
|
14
|
-
args?: string;
|
|
15
|
-
} | {
|
|
16
|
-
type: 'controller';
|
|
17
|
-
moduleNameOrPath: string;
|
|
18
|
-
method: string;
|
|
19
|
-
};
|
|
11
|
+
middleware: MiddlewareHandlerInfo[];
|
|
12
|
+
handler: RouteHandlerInfo;
|
|
20
13
|
};
|
|
21
14
|
/**
|
|
22
15
|
* Routes list formatter is used to format the routes to JSON or an ANSI string
|
|
23
16
|
* with pretty output.
|
|
24
17
|
*
|
|
25
18
|
* The decisions of colors, padding, alignment are all handled by the lists formatter
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* const formatter = new RoutesListFormatter(router, ui, {
|
|
22
|
+
* displayHeadRoutes: false,
|
|
23
|
+
* maxPrettyPrintWidth: 120
|
|
24
|
+
* }, {
|
|
25
|
+
* match: 'api',
|
|
26
|
+
* middleware: ['auth']
|
|
27
|
+
* })
|
|
28
|
+
*
|
|
29
|
+
* const ansiOutput = await formatter.formatAsAnsiList()
|
|
26
30
|
*/
|
|
27
31
|
export declare class RoutesListFormatter {
|
|
28
32
|
#private;
|
|
33
|
+
/**
|
|
34
|
+
* Creates a new instance of the routes list formatter
|
|
35
|
+
*
|
|
36
|
+
* @param router - Router instance containing routes to format
|
|
37
|
+
* @param ui - UI primitives for colors and table formatting
|
|
38
|
+
* @param options - Display options for route formatting
|
|
39
|
+
* @param filters - Filters to apply when displaying routes
|
|
40
|
+
*/
|
|
29
41
|
constructor(router: Router, ui: UIPrimitives, options: {
|
|
30
42
|
displayHeadRoutes?: boolean;
|
|
31
43
|
maxPrettyPrintWidth?: number;
|
|
@@ -7,17 +7,37 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
import stringWidth from 'string-width';
|
|
10
|
-
import { cliHelpers } from
|
|
11
|
-
import {
|
|
10
|
+
import { cliHelpers } from "../../modules/ace/main.js";
|
|
11
|
+
import { middlewareInfo, routeInfo } from '@adonisjs/http-server/helpers';
|
|
12
12
|
/**
|
|
13
13
|
* Routes list formatter is used to format the routes to JSON or an ANSI string
|
|
14
14
|
* with pretty output.
|
|
15
15
|
*
|
|
16
16
|
* The decisions of colors, padding, alignment are all handled by the lists formatter
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* const formatter = new RoutesListFormatter(router, ui, {
|
|
20
|
+
* displayHeadRoutes: false,
|
|
21
|
+
* maxPrettyPrintWidth: 120
|
|
22
|
+
* }, {
|
|
23
|
+
* match: 'api',
|
|
24
|
+
* middleware: ['auth']
|
|
25
|
+
* })
|
|
26
|
+
*
|
|
27
|
+
* const ansiOutput = await formatter.formatAsAnsiList()
|
|
17
28
|
*/
|
|
18
29
|
export class RoutesListFormatter {
|
|
30
|
+
/**
|
|
31
|
+
* Router instance containing all registered routes
|
|
32
|
+
*/
|
|
19
33
|
#router;
|
|
34
|
+
/**
|
|
35
|
+
* Colors utility for ANSI formatting
|
|
36
|
+
*/
|
|
20
37
|
#colors;
|
|
38
|
+
/**
|
|
39
|
+
* Table utility for creating formatted tables
|
|
40
|
+
*/
|
|
21
41
|
#table;
|
|
22
42
|
/**
|
|
23
43
|
* Options for printing routes
|
|
@@ -27,6 +47,14 @@ export class RoutesListFormatter {
|
|
|
27
47
|
* Filters to apply when finding routes
|
|
28
48
|
*/
|
|
29
49
|
#filters;
|
|
50
|
+
/**
|
|
51
|
+
* Creates a new instance of the routes list formatter
|
|
52
|
+
*
|
|
53
|
+
* @param router - Router instance containing routes to format
|
|
54
|
+
* @param ui - UI primitives for colors and table formatting
|
|
55
|
+
* @param options - Display options for route formatting
|
|
56
|
+
* @param filters - Filters to apply when displaying routes
|
|
57
|
+
*/
|
|
30
58
|
constructor(router, ui, options, filters) {
|
|
31
59
|
this.#router = router;
|
|
32
60
|
this.#colors = ui.colors;
|
|
@@ -49,7 +77,7 @@ export class RoutesListFormatter {
|
|
|
49
77
|
if (name === '*') {
|
|
50
78
|
return route.middleware.length > 0;
|
|
51
79
|
}
|
|
52
|
-
return route.middleware.
|
|
80
|
+
return route.middleware.find((middleware) => middleware.name === name);
|
|
53
81
|
});
|
|
54
82
|
}
|
|
55
83
|
/**
|
|
@@ -61,7 +89,7 @@ export class RoutesListFormatter {
|
|
|
61
89
|
if (name === '*') {
|
|
62
90
|
return route.middleware.length === 0;
|
|
63
91
|
}
|
|
64
|
-
return !route.middleware.
|
|
92
|
+
return !route.middleware.find((middleware) => middleware.name === name);
|
|
65
93
|
});
|
|
66
94
|
}
|
|
67
95
|
/**
|
|
@@ -95,43 +123,6 @@ export class RoutesListFormatter {
|
|
|
95
123
|
*/
|
|
96
124
|
return false;
|
|
97
125
|
}
|
|
98
|
-
/**
|
|
99
|
-
* Serialize route middleware to an array of names
|
|
100
|
-
*/
|
|
101
|
-
#serializeMiddleware(middleware) {
|
|
102
|
-
return [...middleware.all()].reduce((result, one) => {
|
|
103
|
-
if (typeof one === 'function') {
|
|
104
|
-
result.push(one.name || 'closure');
|
|
105
|
-
return result;
|
|
106
|
-
}
|
|
107
|
-
if ('name' in one && one.name) {
|
|
108
|
-
result.push(one.name);
|
|
109
|
-
}
|
|
110
|
-
return result;
|
|
111
|
-
}, []);
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Serialize route handler reference to display object
|
|
115
|
-
*/
|
|
116
|
-
async #serializeHandler(handler) {
|
|
117
|
-
/**
|
|
118
|
-
* Value is a controller reference
|
|
119
|
-
*/
|
|
120
|
-
if ('reference' in handler) {
|
|
121
|
-
return {
|
|
122
|
-
type: 'controller',
|
|
123
|
-
...(await parseBindingReference(handler.reference)),
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Value is an inline closure
|
|
128
|
-
*/
|
|
129
|
-
return {
|
|
130
|
-
type: 'closure',
|
|
131
|
-
name: handler.name || 'closure',
|
|
132
|
-
args: 'listArgs' in handler ? String(handler.listArgs) : undefined,
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
126
|
/**
|
|
136
127
|
* Serializes routes JSON to an object that can be used for pretty printing
|
|
137
128
|
*/
|
|
@@ -140,12 +131,15 @@ export class RoutesListFormatter {
|
|
|
140
131
|
if (!this.#options.displayHeadRoutes) {
|
|
141
132
|
methods = methods.filter((method) => method !== 'HEAD');
|
|
142
133
|
}
|
|
134
|
+
const middlewareList = await Promise.all([...route.middleware.all()].map((middleware) => {
|
|
135
|
+
return middlewareInfo(middleware);
|
|
136
|
+
}));
|
|
143
137
|
return {
|
|
144
138
|
name: route.name || '',
|
|
145
139
|
pattern: route.pattern,
|
|
146
140
|
methods: methods,
|
|
147
|
-
handler: await
|
|
148
|
-
middleware:
|
|
141
|
+
handler: await routeInfo(route),
|
|
142
|
+
middleware: middlewareList.filter((info) => info.type !== 'global'),
|
|
149
143
|
};
|
|
150
144
|
}
|
|
151
145
|
/**
|
|
@@ -201,12 +195,15 @@ export class RoutesListFormatter {
|
|
|
201
195
|
*/
|
|
202
196
|
#formatMiddleware(route, mode = 'normal') {
|
|
203
197
|
if (mode === 'compact' && route.middleware.length > 3) {
|
|
204
|
-
const firstMiddleware = route.middleware[0];
|
|
205
|
-
const secondMiddleware = route.middleware[1];
|
|
198
|
+
const firstMiddleware = route.middleware[0].name;
|
|
199
|
+
const secondMiddleware = route.middleware[1].name;
|
|
206
200
|
const diff = route.middleware.length - 2;
|
|
207
201
|
return this.#colors.dim(`${firstMiddleware}, ${secondMiddleware}, and ${diff} more`);
|
|
208
202
|
}
|
|
209
|
-
return this.#colors.dim(`${route.middleware
|
|
203
|
+
return this.#colors.dim(`${route.middleware
|
|
204
|
+
.map((one) => one.name)
|
|
205
|
+
.filter((one) => one)
|
|
206
|
+
.join(', ')}`);
|
|
210
207
|
}
|
|
211
208
|
/**
|
|
212
209
|
* Formatting the domain headling to be in green color with
|
|
@@ -1,9 +1,54 @@
|
|
|
1
|
-
import { ApplicationService, ConfigProvider } from './types.
|
|
1
|
+
import { type ApplicationService, type ConfigProvider } from './types.ts';
|
|
2
2
|
/**
|
|
3
|
-
* Helper to create
|
|
4
|
-
*
|
|
3
|
+
* Helper utilities to create and resolve config providers. Config providers
|
|
4
|
+
* are used to defer configuration resolution until the application is booted,
|
|
5
|
+
* allowing access to environment variables and other application services.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* // Creating a database config provider
|
|
9
|
+
* const databaseConfig = configProvider.create(async (app) => ({
|
|
10
|
+
* connection: app.env.get('DB_CONNECTION', 'sqlite'),
|
|
11
|
+
* host: app.env.get('DB_HOST', 'localhost'),
|
|
12
|
+
* port: app.env.get('DB_PORT', 5432)
|
|
13
|
+
* }))
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Resolving a config provider
|
|
17
|
+
* const config = await configProvider.resolve(app, databaseConfig)
|
|
18
|
+
* if (config) {
|
|
19
|
+
* console.log(`Database connection: ${config.connection}`)
|
|
20
|
+
* }
|
|
5
21
|
*/
|
|
6
22
|
export declare const configProvider: {
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new config provider that will resolve configuration
|
|
25
|
+
* when the application is booted.
|
|
26
|
+
*
|
|
27
|
+
* @param resolver - Function that receives the application service and returns the configuration
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* const mailConfig = configProvider.create(async (app) => ({
|
|
31
|
+
* driver: app.env.get('MAIL_DRIVER', 'smtp'),
|
|
32
|
+
* host: app.env.get('SMTP_HOST'),
|
|
33
|
+
* port: app.env.get('SMTP_PORT', 587)
|
|
34
|
+
* }))
|
|
35
|
+
*/
|
|
7
36
|
create<T>(resolver: ConfigProvider<T>["resolver"]): ConfigProvider<T>;
|
|
37
|
+
/**
|
|
38
|
+
* Resolves a config provider if the provided value is a valid config provider,
|
|
39
|
+
* otherwise returns null.
|
|
40
|
+
*
|
|
41
|
+
* @param app - The application service instance
|
|
42
|
+
* @param provider - The potential config provider to resolve
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* const resolved = await configProvider.resolve(app, someProvider)
|
|
46
|
+
* if (resolved) {
|
|
47
|
+
* // Use the resolved configuration
|
|
48
|
+
* console.log('Config resolved:', resolved)
|
|
49
|
+
* } else {
|
|
50
|
+
* console.log('Not a valid config provider')
|
|
51
|
+
* }
|
|
52
|
+
*/
|
|
8
53
|
resolve<T>(app: ApplicationService, provider: unknown): Promise<T | null>;
|
|
9
54
|
};
|
|
@@ -7,16 +7,61 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
|
-
* Helper to create
|
|
11
|
-
*
|
|
10
|
+
* Helper utilities to create and resolve config providers. Config providers
|
|
11
|
+
* are used to defer configuration resolution until the application is booted,
|
|
12
|
+
* allowing access to environment variables and other application services.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // Creating a database config provider
|
|
16
|
+
* const databaseConfig = configProvider.create(async (app) => ({
|
|
17
|
+
* connection: app.env.get('DB_CONNECTION', 'sqlite'),
|
|
18
|
+
* host: app.env.get('DB_HOST', 'localhost'),
|
|
19
|
+
* port: app.env.get('DB_PORT', 5432)
|
|
20
|
+
* }))
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* // Resolving a config provider
|
|
24
|
+
* const config = await configProvider.resolve(app, databaseConfig)
|
|
25
|
+
* if (config) {
|
|
26
|
+
* console.log(`Database connection: ${config.connection}`)
|
|
27
|
+
* }
|
|
12
28
|
*/
|
|
13
29
|
export const configProvider = {
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new config provider that will resolve configuration
|
|
32
|
+
* when the application is booted.
|
|
33
|
+
*
|
|
34
|
+
* @param resolver - Function that receives the application service and returns the configuration
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* const mailConfig = configProvider.create(async (app) => ({
|
|
38
|
+
* driver: app.env.get('MAIL_DRIVER', 'smtp'),
|
|
39
|
+
* host: app.env.get('SMTP_HOST'),
|
|
40
|
+
* port: app.env.get('SMTP_PORT', 587)
|
|
41
|
+
* }))
|
|
42
|
+
*/
|
|
14
43
|
create(resolver) {
|
|
15
44
|
return {
|
|
16
45
|
type: 'provider',
|
|
17
46
|
resolver,
|
|
18
47
|
};
|
|
19
48
|
},
|
|
49
|
+
/**
|
|
50
|
+
* Resolves a config provider if the provided value is a valid config provider,
|
|
51
|
+
* otherwise returns null.
|
|
52
|
+
*
|
|
53
|
+
* @param app - The application service instance
|
|
54
|
+
* @param provider - The potential config provider to resolve
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* const resolved = await configProvider.resolve(app, someProvider)
|
|
58
|
+
* if (resolved) {
|
|
59
|
+
* // Use the resolved configuration
|
|
60
|
+
* console.log('Config resolved:', resolved)
|
|
61
|
+
* } else {
|
|
62
|
+
* console.log('Not a valid config provider')
|
|
63
|
+
* }
|
|
64
|
+
*/
|
|
20
65
|
async resolve(app, provider) {
|
|
21
66
|
if (provider && typeof provider === 'object' && 'type' in provider) {
|
|
22
67
|
return provider.resolver(app);
|
package/build/src/debug.d.ts
CHANGED
|
@@ -1,2 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debug utility for AdonisJS core. This uses Node.js built-in debuglog
|
|
3
|
+
* utility to provide debugging information when the NODE_DEBUG environment
|
|
4
|
+
* variable includes 'adonisjs:core'.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* // Enable debugging by setting environment variable
|
|
8
|
+
* // NODE_DEBUG=adonisjs:core node app.js
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* // Usage in code
|
|
12
|
+
* import debug from '@adonisjs/core/debug'
|
|
13
|
+
* debug('Application started')
|
|
14
|
+
* debug('Processing request: %s', req.url)
|
|
15
|
+
*/
|
|
1
16
|
declare const _default: import("util").DebugLogger;
|
|
2
17
|
export default _default;
|
package/build/src/debug.js
CHANGED
|
@@ -7,4 +7,19 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
import { debuglog } from 'node:util';
|
|
10
|
+
/**
|
|
11
|
+
* Debug utility for AdonisJS core. This uses Node.js built-in debuglog
|
|
12
|
+
* utility to provide debugging information when the NODE_DEBUG environment
|
|
13
|
+
* variable includes 'adonisjs:core'.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Enable debugging by setting environment variable
|
|
17
|
+
* // NODE_DEBUG=adonisjs:core node app.js
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Usage in code
|
|
21
|
+
* import debug from '@adonisjs/core/debug'
|
|
22
|
+
* debug('Application started')
|
|
23
|
+
* debug('Processing request: %s', req.url)
|
|
24
|
+
*/
|
|
10
25
|
export default debuglog('adonisjs:core');
|
|
@@ -1 +1,41 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Core exception classes and utilities for AdonisJS. This module re-exports
|
|
3
|
+
* commonly used exception classes from @poppinss/utils for creating and
|
|
4
|
+
* handling errors in AdonisJS applications.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* // Creating a custom exception
|
|
8
|
+
* import { Exception } from '@adonisjs/core/exceptions'
|
|
9
|
+
*
|
|
10
|
+
* class ValidationException extends Exception {
|
|
11
|
+
* static status = 422
|
|
12
|
+
* static code = 'E_VALIDATION_FAILURE'
|
|
13
|
+
* }
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Using createError to create custom error classes
|
|
17
|
+
* import { createError } from '@adonisjs/core/exceptions'
|
|
18
|
+
*
|
|
19
|
+
* const UserNotFound = createError('User not found', 'E_USER_NOT_FOUND', 404)
|
|
20
|
+
* throw new UserNotFound()
|
|
21
|
+
*/
|
|
22
|
+
export {
|
|
23
|
+
/**
|
|
24
|
+
* Base exception class for creating custom exceptions with status codes,
|
|
25
|
+
* error codes, and additional context.
|
|
26
|
+
*/
|
|
27
|
+
Exception,
|
|
28
|
+
/**
|
|
29
|
+
* Utility function to create custom error classes with predefined
|
|
30
|
+
* message, code, and status.
|
|
31
|
+
*/
|
|
32
|
+
createError,
|
|
33
|
+
/**
|
|
34
|
+
* Runtime exception class for errors that occur during application runtime.
|
|
35
|
+
*/
|
|
36
|
+
RuntimeException,
|
|
37
|
+
/**
|
|
38
|
+
* Exception class for invalid argument errors, typically used in function
|
|
39
|
+
* parameter validation.
|
|
40
|
+
*/
|
|
41
|
+
InvalidArgumentsException, } from '@poppinss/utils/exception';
|
package/build/src/exceptions.js
CHANGED
|
@@ -6,4 +6,44 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Core exception classes and utilities for AdonisJS. This module re-exports
|
|
11
|
+
* commonly used exception classes from @poppinss/utils for creating and
|
|
12
|
+
* handling errors in AdonisJS applications.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // Creating a custom exception
|
|
16
|
+
* import { Exception } from '@adonisjs/core/exceptions'
|
|
17
|
+
*
|
|
18
|
+
* class ValidationException extends Exception {
|
|
19
|
+
* static status = 422
|
|
20
|
+
* static code = 'E_VALIDATION_FAILURE'
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // Using createError to create custom error classes
|
|
25
|
+
* import { createError } from '@adonisjs/core/exceptions'
|
|
26
|
+
*
|
|
27
|
+
* const UserNotFound = createError('User not found', 'E_USER_NOT_FOUND', 404)
|
|
28
|
+
* throw new UserNotFound()
|
|
29
|
+
*/
|
|
30
|
+
export {
|
|
31
|
+
/**
|
|
32
|
+
* Base exception class for creating custom exceptions with status codes,
|
|
33
|
+
* error codes, and additional context.
|
|
34
|
+
*/
|
|
35
|
+
Exception,
|
|
36
|
+
/**
|
|
37
|
+
* Utility function to create custom error classes with predefined
|
|
38
|
+
* message, code, and status.
|
|
39
|
+
*/
|
|
40
|
+
createError,
|
|
41
|
+
/**
|
|
42
|
+
* Runtime exception class for errors that occur during application runtime.
|
|
43
|
+
*/
|
|
44
|
+
RuntimeException,
|
|
45
|
+
/**
|
|
46
|
+
* Exception class for invalid argument errors, typically used in function
|
|
47
|
+
* parameter validation.
|
|
48
|
+
*/
|
|
49
|
+
InvalidArgumentsException, } from '@poppinss/utils/exception';
|