@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,137 +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.md
|
|
8
|
-
* file that was distributed with this source code.
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.RoutesTableRenderer = void 0;
|
|
12
|
-
const Base_1 = require("./Base");
|
|
13
|
-
/**
|
|
14
|
-
* Renders the routes in a table
|
|
15
|
-
*/
|
|
16
|
-
class RoutesTableRenderer extends Base_1.BaseRender {
|
|
17
|
-
constructor(command) {
|
|
18
|
-
super(command);
|
|
19
|
-
this.routes = this.command.serializeRoutes();
|
|
20
|
-
this.domains = Object.keys(this.routes);
|
|
21
|
-
this.columns = this.getColumnsSize();
|
|
22
|
-
this.longestPatternName = this.getLongestPatterName();
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Returns the length of the longest pattern name among
|
|
26
|
-
* all the routes
|
|
27
|
-
*/
|
|
28
|
-
getLongestPatterName() {
|
|
29
|
-
return (Math.max(...this.domains.map((domain) => {
|
|
30
|
-
return Math.max(...this.routes[domain].map((route) => route.pattern.length));
|
|
31
|
-
})) + 2);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Returns the width for methods column. We limit them at 15 max and
|
|
35
|
-
* return the left over from the column size
|
|
36
|
-
*/
|
|
37
|
-
getMethodsColumnWidth(columnSize) {
|
|
38
|
-
return columnSize < 15
|
|
39
|
-
? { size: columnSize, leftOver: 0 }
|
|
40
|
-
: { size: 15, leftOver: columnSize - 15 };
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Returns the width for all the columns.
|
|
44
|
-
*/
|
|
45
|
-
getColumnsSize() {
|
|
46
|
-
/**
|
|
47
|
-
* Dividing equal column width between all the columns
|
|
48
|
-
*/
|
|
49
|
-
const columnSize = Math.round(this.getRenderingWidth() / 3) - 2;
|
|
50
|
-
/**
|
|
51
|
-
* Limiting the methods column width to 15 cells at max. 90% of the
|
|
52
|
-
* time methods fits within this width, for rest of the cases, they
|
|
53
|
-
* will truncate.
|
|
54
|
-
*/
|
|
55
|
-
const { size: methodsColumnSize, leftOver } = this.getMethodsColumnWidth(columnSize);
|
|
56
|
-
/**
|
|
57
|
-
* Starting wdith for the patterns column and the handlers column.
|
|
58
|
-
*/
|
|
59
|
-
const patternColumnSize = columnSize;
|
|
60
|
-
const handlerColumnSize = columnSize;
|
|
61
|
-
return {
|
|
62
|
-
methodsColumnSize,
|
|
63
|
-
patternColumnSize,
|
|
64
|
-
handlerColumnSize,
|
|
65
|
-
leftOver,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Distributing the left over from the methods column between
|
|
70
|
-
* the pattern column and the handler column.
|
|
71
|
-
*/
|
|
72
|
-
distributeLeftOverBetweenColumns() {
|
|
73
|
-
/**
|
|
74
|
-
* If the pattern width is smaller than the column width itself, then
|
|
75
|
-
* we just give all the left over to the handler column.
|
|
76
|
-
*/
|
|
77
|
-
if (this.longestPatternName < this.columns.patternColumnSize) {
|
|
78
|
-
this.columns.handlerColumnSize += this.columns.leftOver;
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
const cellsNeeded = this.longestPatternName - this.columns.patternColumnSize;
|
|
82
|
-
/**
|
|
83
|
-
* If the pattern column width execeeds the left over width, then
|
|
84
|
-
* we just give the left over to the pattern column. This will
|
|
85
|
-
* also make the pattern column truncate.
|
|
86
|
-
*/
|
|
87
|
-
if (cellsNeeded > this.columns.leftOver) {
|
|
88
|
-
this.columns.patternColumnSize += this.columns.leftOver;
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Finally, we give the cells needed for the pattern column and
|
|
93
|
-
* give the rest to the handler column.
|
|
94
|
-
*/
|
|
95
|
-
this.columns.patternColumnSize += cellsNeeded;
|
|
96
|
-
this.columns.handlerColumnSize += this.columns.leftOver - cellsNeeded;
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
getTable() {
|
|
100
|
-
if (this.columns.leftOver > 0) {
|
|
101
|
-
this.distributeLeftOverBetweenColumns();
|
|
102
|
-
}
|
|
103
|
-
return this.command.ui
|
|
104
|
-
.table()
|
|
105
|
-
.head(['Method', 'Route & Name', 'Handler & Middleware'])
|
|
106
|
-
.columnWidths([
|
|
107
|
-
this.columns.methodsColumnSize,
|
|
108
|
-
this.columns.patternColumnSize,
|
|
109
|
-
this.columns.handlerColumnSize,
|
|
110
|
-
]);
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Render the serialized routes to the console
|
|
114
|
-
*/
|
|
115
|
-
render() {
|
|
116
|
-
const hasCustomDomains = this.domains.find((domain) => domain !== 'root');
|
|
117
|
-
const table = this.getTable();
|
|
118
|
-
this.domains.forEach((domain) => {
|
|
119
|
-
if (hasCustomDomains) {
|
|
120
|
-
table.row([{ colSpan: 3, content: this.command.colors.cyan(domain) }]);
|
|
121
|
-
}
|
|
122
|
-
const domainRoutes = this.routes[domain];
|
|
123
|
-
domainRoutes.forEach((route) => {
|
|
124
|
-
const methodsOutput = this.colorizeRouteMethods(route.methods);
|
|
125
|
-
const patternAndNameOutput = route.name
|
|
126
|
-
? `${this.colorizeRoutePattern(route.pattern)}\n${this.command.colors.gray(route.name)}`
|
|
127
|
-
: this.colorizeRoutePattern(route.pattern);
|
|
128
|
-
const handlerOutput = route.middleware.length
|
|
129
|
-
? `${route.handler}\n${this.command.colors.gray(route.middleware.join('\n'))}`
|
|
130
|
-
: route.handler;
|
|
131
|
-
table.row([methodsOutput, patternAndNameOutput, handlerOutput]);
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
table.render();
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
exports.RoutesTableRenderer = RoutesTableRenderer;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/// <reference types="@adonisjs/http-server/build/adonis-typings" />
|
|
2
|
-
import { BaseCommand } from '@adonisjs/ace';
|
|
3
|
-
import type { RouteNode } from '@ioc:Adonis/Core/Route';
|
|
4
|
-
/**
|
|
5
|
-
* Shape of a route serialized by the ListRoute JSON serializer
|
|
6
|
-
*/
|
|
7
|
-
export type SerializedRoute = {
|
|
8
|
-
domain: string;
|
|
9
|
-
name: string;
|
|
10
|
-
pattern: string;
|
|
11
|
-
handler: string;
|
|
12
|
-
methods: string[];
|
|
13
|
-
middleware: string[];
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* A command to display a list of routes
|
|
17
|
-
*/
|
|
18
|
-
export default class ListRoutes extends BaseCommand {
|
|
19
|
-
static commandName: string;
|
|
20
|
-
static description: string;
|
|
21
|
-
verbose: boolean;
|
|
22
|
-
reverse: boolean;
|
|
23
|
-
methodsFilter: string[];
|
|
24
|
-
patternsFilter: string[];
|
|
25
|
-
namesFilter: string[];
|
|
26
|
-
json: boolean;
|
|
27
|
-
table: boolean;
|
|
28
|
-
maxWidth: number;
|
|
29
|
-
/**
|
|
30
|
-
* Load application
|
|
31
|
-
*/
|
|
32
|
-
static settings: {
|
|
33
|
-
loadApp: boolean;
|
|
34
|
-
stayAlive: boolean;
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Returns the display handler name
|
|
38
|
-
*/
|
|
39
|
-
private getHandlerName;
|
|
40
|
-
/**
|
|
41
|
-
* Apply the method filter on the route
|
|
42
|
-
*/
|
|
43
|
-
private hasPassedMethodFilter;
|
|
44
|
-
/**
|
|
45
|
-
* Apply the pattern filter on the route
|
|
46
|
-
*/
|
|
47
|
-
private hasPassedPatternFilter;
|
|
48
|
-
/**
|
|
49
|
-
* Apply the name filter on the route
|
|
50
|
-
*/
|
|
51
|
-
private hasPassedNameFilter;
|
|
52
|
-
/**
|
|
53
|
-
* Log message
|
|
54
|
-
*/
|
|
55
|
-
private log;
|
|
56
|
-
/**
|
|
57
|
-
* Serialize route to JSON
|
|
58
|
-
*/
|
|
59
|
-
serializeRoute(route: RouteNode & {
|
|
60
|
-
methods: string[];
|
|
61
|
-
}, domain: string): {
|
|
62
|
-
domain: string;
|
|
63
|
-
name: string;
|
|
64
|
-
pattern: string;
|
|
65
|
-
methods: string[];
|
|
66
|
-
handler: string;
|
|
67
|
-
middleware: string[];
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* Returns an array of routes as JSON, filtered according to the
|
|
71
|
-
* flags passed to the command
|
|
72
|
-
*/
|
|
73
|
-
serializeRoutes(): Record<string, SerializedRoute[]>;
|
|
74
|
-
run(): Promise<void>;
|
|
75
|
-
}
|
|
@@ -1,166 +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.md
|
|
8
|
-
* file that was distributed with this source code.
|
|
9
|
-
*/
|
|
10
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
11
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
12
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
13
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
14
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
15
|
-
};
|
|
16
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
17
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
const ace_1 = require("@adonisjs/ace");
|
|
21
|
-
const TableRenderer_1 = require("./Renderers/TableRenderer");
|
|
22
|
-
const PrettyRenderer_1 = require("./Renderers/PrettyRenderer");
|
|
23
|
-
/**
|
|
24
|
-
* A command to display a list of routes
|
|
25
|
-
*/
|
|
26
|
-
class ListRoutes extends ace_1.BaseCommand {
|
|
27
|
-
/**
|
|
28
|
-
* Returns the display handler name
|
|
29
|
-
*/
|
|
30
|
-
getHandlerName(route) {
|
|
31
|
-
const resolvedHandler = route.meta.resolvedHandler;
|
|
32
|
-
if (resolvedHandler.type === 'function') {
|
|
33
|
-
return 'Closure';
|
|
34
|
-
}
|
|
35
|
-
const defaultControllersNamespace = this.application.namespacesMap.get('httpControllers');
|
|
36
|
-
return `${resolvedHandler.namespace.replace(new RegExp(`^${defaultControllersNamespace}\/`), '')}.${resolvedHandler.method}`;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Apply the method filter on the route
|
|
40
|
-
*/
|
|
41
|
-
hasPassedMethodFilter(route) {
|
|
42
|
-
if (!this.methodsFilter || !this.methodsFilter.length) {
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
return !!this.methodsFilter.find((filter) => route.methods.includes(filter.toUpperCase()));
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Apply the pattern filter on the route
|
|
49
|
-
*/
|
|
50
|
-
hasPassedPatternFilter(route) {
|
|
51
|
-
if (!this.patternsFilter || !this.patternsFilter.length) {
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
return !!this.patternsFilter.find((filter) => route.pattern.includes(filter));
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Apply the name filter on the route
|
|
58
|
-
*/
|
|
59
|
-
hasPassedNameFilter(route) {
|
|
60
|
-
if (!this.namesFilter || !this.namesFilter.length) {
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
return !!this.namesFilter.find((filter) => route.name.includes(filter));
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Log message
|
|
67
|
-
*/
|
|
68
|
-
log(message) {
|
|
69
|
-
if (this.application.environment === 'test') {
|
|
70
|
-
this.logger.log(message);
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
console.log(message);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Serialize route to JSON
|
|
78
|
-
*/
|
|
79
|
-
serializeRoute(route, domain) {
|
|
80
|
-
return {
|
|
81
|
-
domain,
|
|
82
|
-
name: route.name || '',
|
|
83
|
-
pattern: route.pattern,
|
|
84
|
-
methods: route.methods,
|
|
85
|
-
handler: this.getHandlerName(route),
|
|
86
|
-
middleware: route.middleware.map((one) => (typeof one === 'function' ? 'Closure' : one)),
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Returns an array of routes as JSON, filtered according to the
|
|
91
|
-
* flags passed to the command
|
|
92
|
-
*/
|
|
93
|
-
serializeRoutes() {
|
|
94
|
-
const Router = this.application.container.use('Adonis/Core/Route');
|
|
95
|
-
Router.commit();
|
|
96
|
-
const routes = Router.toJSON();
|
|
97
|
-
return Object.keys(routes).reduce((result, domain) => {
|
|
98
|
-
const domainRoutes = routes[domain]
|
|
99
|
-
.map((route) => this.serializeRoute(route, domain))
|
|
100
|
-
.filter((route) => {
|
|
101
|
-
return (this.hasPassedMethodFilter(route) &&
|
|
102
|
-
this.hasPassedNameFilter(route) &&
|
|
103
|
-
this.hasPassedPatternFilter(route));
|
|
104
|
-
});
|
|
105
|
-
if (this.reverse) {
|
|
106
|
-
domainRoutes.reverse();
|
|
107
|
-
}
|
|
108
|
-
result[domain] = domainRoutes;
|
|
109
|
-
return result;
|
|
110
|
-
}, {});
|
|
111
|
-
}
|
|
112
|
-
async run() {
|
|
113
|
-
if (this.json) {
|
|
114
|
-
this.log(JSON.stringify(this.serializeRoutes(), null, 2));
|
|
115
|
-
}
|
|
116
|
-
else if (this.table) {
|
|
117
|
-
new TableRenderer_1.RoutesTableRenderer(this).render();
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
new PrettyRenderer_1.RoutesPrettyRenderer(this).render();
|
|
121
|
-
}
|
|
122
|
-
await this.application.shutdown();
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
ListRoutes.commandName = 'list:routes';
|
|
126
|
-
ListRoutes.description = 'List application routes';
|
|
127
|
-
/**
|
|
128
|
-
* Load application
|
|
129
|
-
*/
|
|
130
|
-
ListRoutes.settings = {
|
|
131
|
-
loadApp: true,
|
|
132
|
-
stayAlive: true,
|
|
133
|
-
};
|
|
134
|
-
__decorate([
|
|
135
|
-
ace_1.flags.boolean({ name: 'verbose', description: 'Display more information' }),
|
|
136
|
-
__metadata("design:type", Boolean)
|
|
137
|
-
], ListRoutes.prototype, "verbose", void 0);
|
|
138
|
-
__decorate([
|
|
139
|
-
ace_1.flags.boolean({ alias: 'r', name: 'reverse', description: 'Reverse routes display' }),
|
|
140
|
-
__metadata("design:type", Boolean)
|
|
141
|
-
], ListRoutes.prototype, "reverse", void 0);
|
|
142
|
-
__decorate([
|
|
143
|
-
ace_1.flags.array({ alias: 'm', name: 'methods', description: 'Filter routes by method' }),
|
|
144
|
-
__metadata("design:type", Array)
|
|
145
|
-
], ListRoutes.prototype, "methodsFilter", void 0);
|
|
146
|
-
__decorate([
|
|
147
|
-
ace_1.flags.array({ alias: 'p', name: 'patterns', description: 'Filter routes by the route pattern' }),
|
|
148
|
-
__metadata("design:type", Array)
|
|
149
|
-
], ListRoutes.prototype, "patternsFilter", void 0);
|
|
150
|
-
__decorate([
|
|
151
|
-
ace_1.flags.array({ alias: 'n', name: 'names', description: 'Filter routes by route name' }),
|
|
152
|
-
__metadata("design:type", Array)
|
|
153
|
-
], ListRoutes.prototype, "namesFilter", void 0);
|
|
154
|
-
__decorate([
|
|
155
|
-
ace_1.flags.boolean({ description: 'Output as JSON' }),
|
|
156
|
-
__metadata("design:type", Boolean)
|
|
157
|
-
], ListRoutes.prototype, "json", void 0);
|
|
158
|
-
__decorate([
|
|
159
|
-
ace_1.flags.boolean({ description: 'Output as Table' }),
|
|
160
|
-
__metadata("design:type", Boolean)
|
|
161
|
-
], ListRoutes.prototype, "table", void 0);
|
|
162
|
-
__decorate([
|
|
163
|
-
ace_1.flags.number({ description: 'Specify maximum rendering width. Ignored for JSON Output' }),
|
|
164
|
-
__metadata("design:type", Number)
|
|
165
|
-
], ListRoutes.prototype, "maxWidth", void 0);
|
|
166
|
-
exports.default = ListRoutes;
|
package/build/commands/index.js
DELETED
|
@@ -1,15 +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.default = [
|
|
12
|
-
'@adonisjs/core/build/commands/DumpRc.js',
|
|
13
|
-
'@adonisjs/core/build/commands/ListRoutes/index',
|
|
14
|
-
'@adonisjs/core/build/commands/GenerateKey.js',
|
|
15
|
-
];
|
package/build/config.d.ts
DELETED
package/build/config.js
DELETED
|
@@ -1,15 +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.driveConfig = exports.hashConfig = void 0;
|
|
12
|
-
var config_1 = require("@adonisjs/hash/build/config");
|
|
13
|
-
Object.defineProperty(exports, "hashConfig", { enumerable: true, get: function () { return config_1.hashConfig; } });
|
|
14
|
-
var config_2 = require("@adonisjs/drive/build/config");
|
|
15
|
-
Object.defineProperty(exports, "driveConfig", { enumerable: true, get: function () { return config_2.driveConfig; } });
|
package/build/instructions.js
DELETED
|
@@ -1,81 +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
|
-
const path_1 = require("path");
|
|
12
|
-
const helpers_1 = require("@poppinss/utils/build/helpers");
|
|
13
|
-
const ENV_VALIDATIONS_TEMPLATE_STUB = (0, path_1.join)(__dirname, './templates', 'env.txt');
|
|
14
|
-
const STATIC_TEMPLATE_STUB = (0, path_1.join)(__dirname, './templates', 'config', 'static.txt');
|
|
15
|
-
const APP_CONFIG_TEMPLATE_STUB = (0, path_1.join)(__dirname, './templates', 'config', 'app.txt');
|
|
16
|
-
/**
|
|
17
|
-
* Configure package
|
|
18
|
-
*/
|
|
19
|
-
async function instructions(projectRoot, _, { logger, files }) {
|
|
20
|
-
const isApiBoilerplate = process.env['ADONIS_CREATE_APP_BOILERPLATE'] === 'api';
|
|
21
|
-
const assetsManager = process.env['ADONIS_CREATE_APP_ENCORE'] === 'true';
|
|
22
|
-
/**
|
|
23
|
-
* Create app config file
|
|
24
|
-
*/
|
|
25
|
-
const appConfig = new files.MustacheFile(projectRoot, 'config/app.ts', APP_CONFIG_TEMPLATE_STUB);
|
|
26
|
-
if (appConfig.exists()) {
|
|
27
|
-
logger.action('create').skipped('config/app.ts', 'File already exists');
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
appConfig.apply({ forceContentNegotiationToJSON: isApiBoilerplate, assetsManager }).commit();
|
|
31
|
-
logger.action('create').succeeded('config/app.ts');
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Create static config file when boilerplate is not for the api
|
|
35
|
-
*/
|
|
36
|
-
if (!isApiBoilerplate) {
|
|
37
|
-
const staticConfig = new files.MustacheFile(projectRoot, 'config/static.ts', STATIC_TEMPLATE_STUB);
|
|
38
|
-
if (staticConfig.exists()) {
|
|
39
|
-
logger.action('create').skipped('config/static.ts', 'File already exists');
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
staticConfig.apply({}).commit();
|
|
43
|
-
logger.action('create').succeeded('config/static.ts');
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Add `public` folder to the meta files when not selected api
|
|
48
|
-
* boilerplate
|
|
49
|
-
*/
|
|
50
|
-
if (!isApiBoilerplate) {
|
|
51
|
-
const rcFile = new files.AdonisRcFile(projectRoot);
|
|
52
|
-
rcFile.addMetaFile('public/**', false);
|
|
53
|
-
rcFile.commit();
|
|
54
|
-
logger.action(rcFile.exists() ? 'update' : 'create').succeeded('.adonisrc.json');
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Create .env file for holding environment variables during
|
|
58
|
-
* development
|
|
59
|
-
*/
|
|
60
|
-
const env = new files.EnvFile(projectRoot);
|
|
61
|
-
env.set('PORT', 3333);
|
|
62
|
-
env.set('HOST', '0.0.0.0');
|
|
63
|
-
env.set('NODE_ENV', 'development');
|
|
64
|
-
env.set('APP_KEY', helpers_1.string.generateRandom(32));
|
|
65
|
-
env.set('DRIVE_DISK', 'local');
|
|
66
|
-
env.commit();
|
|
67
|
-
logger.action(env.exists() ? 'update' : 'create').succeeded('.env,.env.example');
|
|
68
|
-
/**
|
|
69
|
-
* Create env.ts file for performing environment variable validations
|
|
70
|
-
*/
|
|
71
|
-
const envTsFile = new files.MustacheFile(projectRoot, 'env.ts', ENV_VALIDATIONS_TEMPLATE_STUB);
|
|
72
|
-
envTsFile.apply({ assetsManager });
|
|
73
|
-
if (envTsFile.exists()) {
|
|
74
|
-
logger.action('create').skipped('env.ts');
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
envTsFile.apply({}).commit();
|
|
78
|
-
logger.action('create').succeeded('env.ts');
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
exports.default = instructions;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { ApplicationContract } from '@ioc:Adonis/Core/Application';
|
|
2
|
-
/**
|
|
3
|
-
* The application provider that sticks all core components
|
|
4
|
-
* to the container.
|
|
5
|
-
*/
|
|
6
|
-
export default class AppProvider {
|
|
7
|
-
protected app: ApplicationContract;
|
|
8
|
-
constructor(app: ApplicationContract);
|
|
9
|
-
static needsApplication: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Find if web or test environment
|
|
12
|
-
*/
|
|
13
|
-
private isWebOrTestEnvironment;
|
|
14
|
-
/**
|
|
15
|
-
* Additional providers to load
|
|
16
|
-
*/
|
|
17
|
-
provides: string[];
|
|
18
|
-
/**
|
|
19
|
-
* Register `HttpExceptionHandler` to the container.
|
|
20
|
-
*/
|
|
21
|
-
protected registerHttpExceptionHandler(): void;
|
|
22
|
-
/**
|
|
23
|
-
* Registering the health check provider
|
|
24
|
-
*/
|
|
25
|
-
protected registerHealthCheck(): void;
|
|
26
|
-
/**
|
|
27
|
-
* Registering the assets manager
|
|
28
|
-
*/
|
|
29
|
-
protected registerAssetsManager(): void;
|
|
30
|
-
/**
|
|
31
|
-
* Lazy initialize the cors hook, if enabled inside the config
|
|
32
|
-
*/
|
|
33
|
-
protected registerCorsHook(): void;
|
|
34
|
-
/**
|
|
35
|
-
* Lazy initialize the static assets hook, if enabled inside the config
|
|
36
|
-
*/
|
|
37
|
-
protected registerStaticAssetsHook(): void;
|
|
38
|
-
/**
|
|
39
|
-
* Registers base health checkers
|
|
40
|
-
*/
|
|
41
|
-
protected registerHealthCheckers(): void;
|
|
42
|
-
/**
|
|
43
|
-
* Register ace kernel to the container. When the process is started
|
|
44
|
-
* by running an ace command, then the "Adonis/Core/Ace" binding
|
|
45
|
-
* will already be in place and hence we do not overwrite it.
|
|
46
|
-
*/
|
|
47
|
-
protected registerAceKernel(): void;
|
|
48
|
-
/**
|
|
49
|
-
* Register utilities object required during testing
|
|
50
|
-
*/
|
|
51
|
-
protected registerTestUtils(): void;
|
|
52
|
-
/**
|
|
53
|
-
* Define repl bindings
|
|
54
|
-
*/
|
|
55
|
-
protected defineReplBindings(): void;
|
|
56
|
-
/**
|
|
57
|
-
* Define bindings for japa tests
|
|
58
|
-
*/
|
|
59
|
-
protected defineTestsBindings(): void;
|
|
60
|
-
/**
|
|
61
|
-
* Registering all required bindings to the container
|
|
62
|
-
*/
|
|
63
|
-
register(): void;
|
|
64
|
-
/**
|
|
65
|
-
* Register hooks and health checkers on boot
|
|
66
|
-
*/
|
|
67
|
-
boot(): void;
|
|
68
|
-
}
|