@adonisjs/core 7.0.1 → 7.1.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/ace-DBm6EcQ-.js +37 -0
- package/build/app-BCcG_oDd.js +7 -0
- package/build/app-CAuSGb2P.js +15 -0
- package/build/bodyparser_middleware-H5FArWkI.js +9 -0
- package/build/{chunk-iKc69rpz.js → chunk-Do49iUES.js} +3 -0
- package/build/commands/add.d.ts +1 -0
- package/build/commands/add.js +64 -10
- package/build/commands/build.js +41 -3
- package/build/commands/commands.json +1 -1
- package/build/commands/configure.js +70 -4
- package/build/commands/eject.js +30 -4
- package/build/commands/env/add.js +62 -4
- package/build/commands/generate_key.js +23 -3
- package/build/commands/inspect_rcfile.js +26 -2
- package/build/commands/list/routes.d.ts +5 -0
- package/build/commands/list/routes.js +242 -3
- package/build/commands/make/command.js +33 -4
- package/build/commands/make/controller.js +46 -4
- package/build/commands/make/event.js +36 -4
- package/build/commands/make/exception.js +36 -4
- package/build/commands/make/listener.js +44 -4
- package/build/commands/make/middleware.js +53 -5
- package/build/commands/make/preload.js +55 -5
- package/build/commands/make/provider.js +54 -5
- package/build/commands/make/service.js +29 -4
- package/build/commands/make/test.js +63 -4
- package/build/commands/make/transformer.js +37 -4
- package/build/commands/make/validator.js +44 -4
- package/build/commands/make/view.js +33 -4
- package/build/commands/repl.js +31 -2
- package/build/commands/serve.js +54 -4
- package/build/commands/test.js +69 -4
- package/build/config-Coti2q6R.js +7 -0
- package/build/config_provider-Do9af1ze.js +35 -0
- package/build/container-CGfEwWof.js +7 -0
- package/build/{core-IpCOCkUL.js → core-XjMm_ipu.js} +51 -2
- package/build/create_kernel-BV3swyCg.js +4 -0
- package/build/{create_kernel-B7ILNhuP.js → create_kernel-D38-0Zbt.js} +41 -1
- package/build/debug-DWofTfIX.js +20 -0
- package/build/{decorate-DmrZA614.js → decorate-B9Uz0anB.js} +2 -0
- package/build/{define_config-0oHaj43l.js → define_config--5euEdi8.js} +54 -3
- package/build/dumper-3R77st8F.js +353 -0
- package/build/edge-BG5ZYp6Z.js +57 -0
- package/build/{errors-CrCO-k44.js → errors-BScZTzBu.js} +9 -1
- package/build/events-DlKX1ZdL.js +7 -0
- package/build/exceptions-B2MzIlHY.js +2 -0
- package/build/factories/app.js +1 -0
- package/build/factories/bodyparser.js +1 -0
- package/build/factories/core/ace.js +16 -22
- package/build/factories/core/ignitor.js +13 -73
- package/build/factories/core/main.js +25 -17
- package/build/factories/core/test_utils.js +22 -19
- package/build/factories/encryption.js +1 -0
- package/build/factories/events.js +1 -0
- package/build/factories/hash.js +1 -0
- package/build/factories/http.js +1 -0
- package/build/factories/logger.js +1 -0
- package/build/factories/stubs.js +75 -7
- package/build/ignitor-Kym3gR-I.js +169 -0
- package/build/index.js +11 -8
- package/build/logger-DIdZPHCe.js +43 -0
- package/build/main-B50zECAi.js +121 -0
- package/build/main-CRnMnrH7.js +184 -0
- package/build/{main-kn40V-hF.js → main-CfTiGsiS.js} +2 -0
- package/build/main-Ck0GqLx4.js +117 -0
- package/build/main-CoZI4Ezs.js +2 -0
- package/build/main-D1MSq4Uu.js +435 -0
- package/build/{main--nXd7T-C.js → main-bRYXIHgD.js} +75 -3
- package/build/main-zxNP7iRl.js +7 -0
- package/build/modules/ace/codemods.js +301 -2
- package/build/modules/ace/commands.d.ts +5 -0
- package/build/modules/ace/main.js +2 -1
- package/build/modules/app.js +3 -5
- package/build/modules/bodyparser/bodyparser_middleware.js +2 -2
- package/build/modules/bodyparser/main.js +3 -5
- package/build/modules/config.js +3 -5
- package/build/modules/container.js +3 -5
- package/build/modules/dumper/main.js +29 -2
- package/build/modules/dumper/plugins/edge.js +2 -46
- package/build/modules/encryption/drivers/aes_256_cbc.js +1 -0
- package/build/modules/encryption/drivers/aes_256_gcm.js +1 -0
- package/build/modules/encryption/drivers/aes_siv.js +1 -0
- package/build/modules/encryption/drivers/chacha20_poly1305.js +1 -0
- package/build/modules/encryption/drivers/legacy.js +46 -1
- package/build/modules/encryption/main.js +7 -5
- package/build/modules/env/editor.js +1 -0
- package/build/modules/env/main.js +1 -0
- package/build/modules/events.js +3 -5
- package/build/modules/hash/drivers/argon.js +1 -0
- package/build/modules/hash/drivers/bcrypt.js +1 -0
- package/build/modules/hash/drivers/scrypt.js +1 -0
- package/build/modules/hash/main.js +4 -4
- package/build/modules/hash/phc_formatter.js +1 -0
- package/build/modules/health.js +1 -0
- package/build/modules/http/helpers.js +1 -0
- package/build/modules/http/main.js +2 -2
- package/build/modules/http/url_builder_client.js +1 -0
- package/build/modules/logger.js +3 -13
- package/build/modules/repl.js +3 -5
- package/build/modules/transformers/main.js +1 -0
- package/build/providers/app_provider.js +214 -15
- package/build/providers/edge_provider.js +90 -3
- package/build/providers/hash_provider.js +59 -4
- package/build/providers/repl_provider.js +64 -2
- package/build/providers/vinejs_provider.js +44 -3
- package/build/repl-C02Re0Yd.js +7 -0
- package/build/services/ace.js +11 -1
- package/build/services/app.js +2 -4
- package/build/services/config.js +7 -1
- package/build/services/dumper.js +13 -1
- package/build/services/emitter.js +8 -1
- package/build/services/encryption.js +8 -1
- package/build/services/hash.js +8 -1
- package/build/services/logger.js +8 -1
- package/build/services/repl.js +8 -1
- package/build/services/router.js +8 -1
- package/build/services/server.js +8 -1
- package/build/services/test_utils.js +11 -1
- package/build/services/url_builder.js +8 -1
- package/build/src/cli_formatters/routes_list.d.ts +7 -0
- package/build/src/exceptions.js +2 -1
- package/build/src/helpers/assert.js +1 -0
- package/build/src/helpers/http.js +1 -0
- package/build/src/helpers/is.js +24 -0
- package/build/src/helpers/main.js +2 -1
- package/build/src/helpers/string.js +2 -27
- package/build/src/helpers/types.js +18 -0
- package/build/src/helpers/verification_token.js +2 -45
- package/build/src/test_utils/main.js +9 -7
- package/build/src/types.js +1 -0
- package/build/src/vine.js +2 -32
- package/build/string-8_8He-HH.js +46 -0
- package/build/test_utils-DbJS_uEu.js +32 -0
- package/build/toolkit/main.js +13 -1
- package/build/types/ace.js +1 -0
- package/build/types/app.js +1 -0
- package/build/types/bodyparser.js +1 -0
- package/build/types/common.js +1 -0
- package/build/types/container.js +1 -0
- package/build/types/encryption.js +1 -0
- package/build/types/events.js +1 -0
- package/build/types/hash.js +1 -0
- package/build/types/health.js +1 -0
- package/build/types/helpers.js +1 -0
- package/build/types/http.js +1 -0
- package/build/types/logger.js +1 -0
- package/build/types/repl.js +1 -0
- package/build/types/transformers.js +1 -0
- package/build/utils-CKwka7OL.js +105 -0
- package/build/verification_token-WCrZtUgZ.js +108 -0
- package/build/vine-DkIupA3Z.js +97 -0
- package/package.json +12 -12
- package/build/config_provider-FIAUgvae.js +0 -13
- package/build/create_kernel-BD0Iqi8e.js +0 -3
- package/build/debug-CGQmxzGt.js +0 -3
- package/build/dumper-BBgqFX5a.js +0 -147
- package/build/main-Cxz0TyIw.js +0 -173
- package/build/main-DN2qEEg5.js +0 -41
- package/build/main-DkNgvceD.js +0 -52
- package/build/main-MBAMnmJb.js +0 -81
- package/build/utils-rRkbAPnP.js +0 -42
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import "../../
|
|
2
|
-
import "../../
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
1
|
+
import "../../chunk-Do49iUES.js";
|
|
2
|
+
import "../../debug-DWofTfIX.js";
|
|
3
|
+
import "../../config_provider-Do9af1ze.js";
|
|
4
|
+
import "../../exceptions-B2MzIlHY.js";
|
|
5
|
+
import { n as errors } from "../../errors-BScZTzBu.js";
|
|
6
|
+
import { n as drivers, t as defineConfig } from "../../define_config--5euEdi8.js";
|
|
7
|
+
import { i as Hmac, n as Encryption, r as EncryptionManager, t as BaseDriver } from "../../main-CoZI4Ezs.js";
|
|
6
8
|
export { BaseDriver, Encryption, EncryptionManager, Hmac, defineConfig, drivers, errors };
|
package/build/modules/events.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "../chunk-Do49iUES.js";
|
|
2
|
+
import "../events-DlKX1ZdL.js";
|
|
2
3
|
export * from "@adonisjs/events";
|
|
3
|
-
|
|
4
|
-
import * as import__adonisjs_events from "@adonisjs/events";
|
|
5
|
-
__reExport(events_exports, import__adonisjs_events);
|
|
6
|
-
export { events_exports as t };
|
|
4
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "../../chunk-
|
|
2
|
-
import "../../debug-
|
|
3
|
-
import "../../config_provider-
|
|
4
|
-
import { n as defineConfig, r as drivers } from "../../main-
|
|
1
|
+
import "../../chunk-Do49iUES.js";
|
|
2
|
+
import "../../debug-DWofTfIX.js";
|
|
3
|
+
import "../../config_provider-Do9af1ze.js";
|
|
4
|
+
import { n as defineConfig, r as drivers } from "../../main-B50zECAi.js";
|
|
5
5
|
export * from "@adonisjs/hash";
|
|
6
6
|
export { defineConfig, drivers };
|
package/build/modules/health.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../../chunk-
|
|
2
|
-
import { n as RequestValidator } from "../../main-
|
|
1
|
+
import "../../chunk-Do49iUES.js";
|
|
2
|
+
import { n as RequestValidator } from "../../main-Ck0GqLx4.js";
|
|
3
3
|
export * from "@adonisjs/http-server";
|
|
4
4
|
export { RequestValidator };
|
package/build/modules/logger.js
CHANGED
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import "../chunk-Do49iUES.js";
|
|
2
|
+
import { n as syncDestination } from "../logger-DIdZPHCe.js";
|
|
3
3
|
export * from "@adonisjs/logger";
|
|
4
|
-
|
|
5
|
-
import * as import__adonisjs_logger from "@adonisjs/logger";
|
|
6
|
-
__reExport(logger_exports, import__adonisjs_logger);
|
|
7
|
-
async function syncDestination(options) {
|
|
8
|
-
const { default: pinoPretty, isColorSupported } = await import("pino-pretty");
|
|
9
|
-
return isColorSupported ? pinoPretty({
|
|
10
|
-
...options,
|
|
11
|
-
sync: true
|
|
12
|
-
}) : destination(1);
|
|
13
|
-
}
|
|
14
|
-
export { syncDestination, logger_exports as t };
|
|
4
|
+
export { syncDestination };
|
package/build/modules/repl.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "../chunk-Do49iUES.js";
|
|
2
|
+
import "../repl-C02Re0Yd.js";
|
|
2
3
|
export * from "@adonisjs/repl";
|
|
3
|
-
|
|
4
|
-
import * as import__adonisjs_repl from "@adonisjs/repl";
|
|
5
|
-
__reExport(repl_exports, import__adonisjs_repl);
|
|
6
|
-
export { repl_exports as t };
|
|
4
|
+
export {};
|
|
@@ -1,63 +1,174 @@
|
|
|
1
|
-
import "../chunk-
|
|
2
|
-
import "../debug-
|
|
3
|
-
import { t as app_exports } from "../
|
|
4
|
-
import { t as configProvider } from "../config_provider-
|
|
5
|
-
import { t as config_exports } from "../
|
|
6
|
-
import { t as events_exports } from "../
|
|
7
|
-
import { t as logger_exports } from "../
|
|
8
|
-
import { t as Dumper } from "../dumper-
|
|
9
|
-
import { RuntimeException } from "../
|
|
10
|
-
import { t as main_exports } from "../main-
|
|
11
|
-
import "../errors-
|
|
12
|
-
import "../define_config
|
|
13
|
-
import { Encryption } from "../
|
|
14
|
-
import bodyparser_middleware_default from "../
|
|
1
|
+
import "../chunk-Do49iUES.js";
|
|
2
|
+
import "../debug-DWofTfIX.js";
|
|
3
|
+
import { t as app_exports } from "../app-BCcG_oDd.js";
|
|
4
|
+
import { t as configProvider } from "../config_provider-Do9af1ze.js";
|
|
5
|
+
import { t as config_exports } from "../config-Coti2q6R.js";
|
|
6
|
+
import { t as events_exports } from "../events-DlKX1ZdL.js";
|
|
7
|
+
import { t as logger_exports } from "../logger-DIdZPHCe.js";
|
|
8
|
+
import { t as Dumper } from "../dumper-3R77st8F.js";
|
|
9
|
+
import { r as RuntimeException } from "../exceptions-B2MzIlHY.js";
|
|
10
|
+
import { t as main_exports } from "../main-Ck0GqLx4.js";
|
|
11
|
+
import "../errors-BScZTzBu.js";
|
|
12
|
+
import "../define_config--5euEdi8.js";
|
|
13
|
+
import { n as Encryption } from "../main-CoZI4Ezs.js";
|
|
14
|
+
import { t as bodyparser_middleware_default } from "../bodyparser_middleware-H5FArWkI.js";
|
|
15
15
|
import { dirname } from "node:path";
|
|
16
16
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
17
|
+
//#region providers/app_provider.ts
|
|
18
|
+
/**
|
|
19
|
+
* The Application Service provider registers all the baseline
|
|
20
|
+
* features required to run the framework.
|
|
21
|
+
*
|
|
22
|
+
* This provider handles the registration of core services including:
|
|
23
|
+
* - Application instance
|
|
24
|
+
* - Logger and logger manager
|
|
25
|
+
* - Configuration
|
|
26
|
+
* - Event emitter
|
|
27
|
+
* - Encryption service
|
|
28
|
+
* - HTTP server and router
|
|
29
|
+
* - Body parser middleware
|
|
30
|
+
* - Dumper for debugging
|
|
31
|
+
* - Test utilities and ACE kernel
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* const provider = new AppServiceProvider(app)
|
|
35
|
+
* provider.register()
|
|
36
|
+
* await provider.boot()
|
|
37
|
+
* await provider.ready()
|
|
38
|
+
*/
|
|
17
39
|
var AppServiceProvider = class {
|
|
40
|
+
/**
|
|
41
|
+
* Application service provider constructor
|
|
42
|
+
*
|
|
43
|
+
* @param app - The application service instance
|
|
44
|
+
*/
|
|
18
45
|
constructor(app) {
|
|
19
46
|
this.app = app;
|
|
20
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Registers test utils with the container
|
|
50
|
+
*
|
|
51
|
+
* Creates a singleton binding for 'testUtils' that lazily imports
|
|
52
|
+
* and instantiates the TestUtils class when first accessed.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* const testUtils = await app.container.make('testUtils')
|
|
56
|
+
* testUtils.createHttpContext()
|
|
57
|
+
*/
|
|
21
58
|
registerTestUtils() {
|
|
22
59
|
this.app.container.singleton("testUtils", async () => {
|
|
23
60
|
const { TestUtils } = await import("../src/test_utils/main.js");
|
|
24
61
|
return new TestUtils(this.app);
|
|
25
62
|
});
|
|
26
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Registers ace with the container
|
|
66
|
+
*
|
|
67
|
+
* Creates a singleton binding for 'ace' that lazily creates
|
|
68
|
+
* the ACE kernel for command-line interface functionality.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* const ace = await app.container.make('ace')
|
|
72
|
+
* await ace.exec('make:controller', ['UserController'])
|
|
73
|
+
*/
|
|
27
74
|
registerAce() {
|
|
28
75
|
this.app.container.singleton("ace", async () => {
|
|
29
|
-
const { createAceKernel } = await import("../create_kernel-
|
|
76
|
+
const { createAceKernel } = await import("../create_kernel-BV3swyCg.js");
|
|
30
77
|
return createAceKernel(this.app);
|
|
31
78
|
});
|
|
32
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Registers the application to the container
|
|
82
|
+
*
|
|
83
|
+
* Binds the application instance as both a class binding and an alias.
|
|
84
|
+
* This allows access to the app instance throughout the container.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* const app = await container.make('app')
|
|
88
|
+
* const appPath = app.makePath('tmp')
|
|
89
|
+
*/
|
|
33
90
|
registerApp() {
|
|
34
91
|
this.app.container.singleton(app_exports.Application, () => this.app);
|
|
35
92
|
this.app.container.alias("app", app_exports.Application);
|
|
36
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* Registers the logger class to resolve the default logger
|
|
96
|
+
*
|
|
97
|
+
* Creates a singleton binding for the Logger class that resolves
|
|
98
|
+
* the default logger instance from the logger manager.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* const logger = await container.make(Logger)
|
|
102
|
+
* logger.info('Application started')
|
|
103
|
+
*/
|
|
37
104
|
registerLogger() {
|
|
38
105
|
this.app.container.singleton(logger_exports.Logger, async (resolver) => {
|
|
39
106
|
return (await resolver.make("logger")).use();
|
|
40
107
|
});
|
|
41
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Registers the logger manager to the container
|
|
111
|
+
*
|
|
112
|
+
* Creates a singleton binding for 'logger' that instantiates
|
|
113
|
+
* the LoggerManager with configuration from config/logger.ts
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* const loggerManager = await container.make('logger')
|
|
117
|
+
* const fileLogger = loggerManager.use('file')
|
|
118
|
+
*/
|
|
42
119
|
registerLoggerManager() {
|
|
43
120
|
this.app.container.singleton("logger", async () => {
|
|
44
121
|
const { LoggerManager } = await import("../modules/logger.js");
|
|
45
122
|
return new LoggerManager(this.app.config.get("logger"));
|
|
46
123
|
});
|
|
47
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* Registers the config to the container
|
|
127
|
+
*
|
|
128
|
+
* Binds the application's config instance as both a class binding
|
|
129
|
+
* and an alias, allowing access to configuration values.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* const config = await container.make('config')
|
|
133
|
+
* const appKey = config.get('app.appKey')
|
|
134
|
+
*/
|
|
48
135
|
registerConfig() {
|
|
49
136
|
this.app.container.singleton(config_exports.Config, () => this.app.config);
|
|
50
137
|
this.app.container.alias("config", config_exports.Config);
|
|
51
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Registers emitter service to the container
|
|
141
|
+
*
|
|
142
|
+
* Creates a singleton binding for the event emitter that handles
|
|
143
|
+
* application-wide event dispatching and listening.
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* const emitter = await container.make('emitter')
|
|
147
|
+
* emitter.emit('user:created', { userId: 123 })
|
|
148
|
+
*/
|
|
52
149
|
registerEmitter() {
|
|
53
150
|
this.app.container.singleton(events_exports.Emitter, async () => {
|
|
54
151
|
return new events_exports.Emitter(this.app);
|
|
55
152
|
});
|
|
56
153
|
this.app.container.alias("emitter", events_exports.Emitter);
|
|
57
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Registers the encryption service with the container
|
|
157
|
+
*
|
|
158
|
+
* Creates singleton bindings for both the encryption manager and
|
|
159
|
+
* the default encryption instance. Resolves configuration from
|
|
160
|
+
* config/encryption.ts file.
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* const encryption = await container.make('encryption')
|
|
164
|
+
* const encrypted = encryption.encrypt('secret-data')
|
|
165
|
+
*/
|
|
58
166
|
registerEncryption() {
|
|
59
167
|
this.app.container.singleton("encryption", async () => {
|
|
60
168
|
const encryptionConfigProvider = this.app.config.get("encryption");
|
|
169
|
+
/**
|
|
170
|
+
* Resolve config from the provider
|
|
171
|
+
*/
|
|
61
172
|
const config = await configProvider.resolve(this.app, encryptionConfigProvider);
|
|
62
173
|
if (!config) throw new RuntimeException("Invalid \"config/encryption.ts\" file. Make sure you are using the \"defineConfig\" method");
|
|
63
174
|
const { EncryptionManager } = await import("../modules/encryption/main.js");
|
|
@@ -67,6 +178,17 @@ var AppServiceProvider = class {
|
|
|
67
178
|
return (await resolver.make("encryption")).use();
|
|
68
179
|
});
|
|
69
180
|
}
|
|
181
|
+
/**
|
|
182
|
+
* Registers the HTTP server with the container as a singleton
|
|
183
|
+
*
|
|
184
|
+
* Creates a singleton binding for the HTTP server that handles
|
|
185
|
+
* incoming requests, with dependencies on encryption, emitter,
|
|
186
|
+
* logger, and HTTP configuration.
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* const server = await container.make('server')
|
|
190
|
+
* server.start()
|
|
191
|
+
*/
|
|
70
192
|
registerServer() {
|
|
71
193
|
this.app.container.singleton(main_exports.Server, async (resolver) => {
|
|
72
194
|
const encryption = await resolver.make(Encryption);
|
|
@@ -77,17 +199,49 @@ var AppServiceProvider = class {
|
|
|
77
199
|
});
|
|
78
200
|
this.app.container.alias("server", main_exports.Server);
|
|
79
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* Registers router with the container as a singleton
|
|
204
|
+
*
|
|
205
|
+
* Creates a singleton binding for the router by getting it from
|
|
206
|
+
* the HTTP server instance. The router handles URL routing.
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* const router = await container.make('router')
|
|
210
|
+
* router.get('/', ({ response }) => response.send('Hello'))
|
|
211
|
+
*/
|
|
80
212
|
registerRouter() {
|
|
81
213
|
this.app.container.singleton(main_exports.Router, async (resolver) => {
|
|
82
214
|
return (await resolver.make("server")).getRouter();
|
|
83
215
|
});
|
|
84
216
|
this.app.container.alias("router", main_exports.Router);
|
|
85
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* Self construct bodyparser middleware class, since it needs
|
|
220
|
+
* config that cannot be resolved by the container
|
|
221
|
+
*
|
|
222
|
+
* Binds the BodyParserMiddleware with bodyparser configuration
|
|
223
|
+
* and experimental flags for parsing request bodies.
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* const middleware = await container.make(BodyParserMiddleware)
|
|
227
|
+
* await middleware.handle(ctx, next)
|
|
228
|
+
*/
|
|
86
229
|
registerBodyParserMiddleware() {
|
|
87
230
|
this.app.container.singleton(bodyparser_middleware_default, () => {
|
|
88
231
|
return new bodyparser_middleware_default(this.app.config.get("bodyparser"), this.app.experimentalFlags);
|
|
89
232
|
});
|
|
90
233
|
}
|
|
234
|
+
/**
|
|
235
|
+
* Registeres singleton instance of the "Dumper" module configured
|
|
236
|
+
* via the "config/app.ts" file.
|
|
237
|
+
*
|
|
238
|
+
* The dumper is used for debugging and variable inspection with
|
|
239
|
+
* configurable HTML and console output formats.
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* const dumper = await container.make('dumper')
|
|
243
|
+
* dumper.dump({ user: { name: 'John' } })
|
|
244
|
+
*/
|
|
91
245
|
registerDumper() {
|
|
92
246
|
this.app.container.singleton(Dumper, async () => {
|
|
93
247
|
const config = this.app.config.get("app.dumper", {});
|
|
@@ -98,6 +252,20 @@ var AppServiceProvider = class {
|
|
|
98
252
|
});
|
|
99
253
|
this.app.container.alias("dumper", Dumper);
|
|
100
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* Generates TypeScript type definitions and JSON representation of routes
|
|
257
|
+
*
|
|
258
|
+
* Creates route type definitions for better IDE support and a JSON file
|
|
259
|
+
* containing all registered routes. This is used in development mode for
|
|
260
|
+
* tooling integration and type-safety.
|
|
261
|
+
*
|
|
262
|
+
* @param router - The router instance containing registered routes
|
|
263
|
+
*
|
|
264
|
+
* @example
|
|
265
|
+
* const router = await container.make('router')
|
|
266
|
+
* await this.emitRoutes(router)
|
|
267
|
+
* // Generates .adonisjs/server/routes.d.ts and routes.json
|
|
268
|
+
*/
|
|
101
269
|
async emitRoutes(router) {
|
|
102
270
|
try {
|
|
103
271
|
const { routes, imports, types } = router.generateTypes(2);
|
|
@@ -126,6 +294,16 @@ var AppServiceProvider = class {
|
|
|
126
294
|
console.error(error);
|
|
127
295
|
}
|
|
128
296
|
}
|
|
297
|
+
/**
|
|
298
|
+
* Registers bindings
|
|
299
|
+
*
|
|
300
|
+
* Called during the application bootstrap phase to register
|
|
301
|
+
* all core service bindings with the IoC container.
|
|
302
|
+
*
|
|
303
|
+
* @example
|
|
304
|
+
* const provider = new AppServiceProvider(app)
|
|
305
|
+
* provider.register() // Registers all core services
|
|
306
|
+
*/
|
|
129
307
|
register() {
|
|
130
308
|
this.registerApp();
|
|
131
309
|
this.registerAce();
|
|
@@ -140,9 +318,29 @@ var AppServiceProvider = class {
|
|
|
140
318
|
this.registerRouter();
|
|
141
319
|
this.registerBodyParserMiddleware();
|
|
142
320
|
}
|
|
321
|
+
/**
|
|
322
|
+
* Boot the service provider
|
|
323
|
+
*
|
|
324
|
+
* Called after all providers have been registered. Sets up
|
|
325
|
+
* event emitter for BaseEvent and adds transform macro to HttpContext.
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* await provider.boot()
|
|
329
|
+
* // Now HttpContext has transform method available
|
|
330
|
+
*/
|
|
143
331
|
async boot() {
|
|
144
332
|
events_exports.BaseEvent.useEmitter(await this.app.container.make("emitter"));
|
|
145
333
|
}
|
|
334
|
+
/**
|
|
335
|
+
* Called when the application is ready
|
|
336
|
+
*
|
|
337
|
+
* In non-production environments, generates route types and
|
|
338
|
+
* JSON files for development tooling when router is committed.
|
|
339
|
+
*
|
|
340
|
+
* @example
|
|
341
|
+
* await provider.ready()
|
|
342
|
+
* // Route types and JSON generated in development
|
|
343
|
+
*/
|
|
146
344
|
async ready() {
|
|
147
345
|
if (!this.app.inProduction) {
|
|
148
346
|
const router = await this.app.container.make("router");
|
|
@@ -150,4 +348,5 @@ var AppServiceProvider = class {
|
|
|
150
348
|
}
|
|
151
349
|
}
|
|
152
350
|
};
|
|
351
|
+
//#endregion
|
|
153
352
|
export { AppServiceProvider as default };
|
|
@@ -1,23 +1,76 @@
|
|
|
1
|
-
import "../chunk-
|
|
2
|
-
import { t as main_exports } from "../main-
|
|
3
|
-
import { pluginEdgeDumper } from "../
|
|
1
|
+
import "../chunk-Do49iUES.js";
|
|
2
|
+
import { t as main_exports } from "../main-Ck0GqLx4.js";
|
|
3
|
+
import { t as pluginEdgeDumper } from "../edge-BG5ZYp6Z.js";
|
|
4
4
|
import edge from "edge.js";
|
|
5
|
+
//#region providers/edge_provider.ts
|
|
6
|
+
/**
|
|
7
|
+
* The Edge service provider configures Edge to work within
|
|
8
|
+
* an AdonisJS application environment
|
|
9
|
+
*
|
|
10
|
+
* This provider integrates EdgeJS template engine with AdonisJS by:
|
|
11
|
+
* - Mounting the views directory
|
|
12
|
+
* - Configuring template caching for production
|
|
13
|
+
* - Adding global helpers for route generation
|
|
14
|
+
* - Creating isolated renderer instances for HTTP contexts
|
|
15
|
+
* - Adding render macro to BriskRoute for template rendering
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* const provider = new EdgeServiceProvider(app)
|
|
19
|
+
* await provider.boot()
|
|
20
|
+
*/
|
|
5
21
|
var EdgeServiceProvider = class {
|
|
22
|
+
/**
|
|
23
|
+
* Edge service provider constructor
|
|
24
|
+
*
|
|
25
|
+
* Sets the usingEdgeJS flag to true to indicate EdgeJS is being used.
|
|
26
|
+
*
|
|
27
|
+
* @param app - The application service instance
|
|
28
|
+
*/
|
|
6
29
|
constructor(app) {
|
|
7
30
|
this.app = app;
|
|
8
31
|
this.app.usingEdgeJS = true;
|
|
9
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Bridge AdonisJS and Edge
|
|
35
|
+
*
|
|
36
|
+
* Configures EdgeJS integration by:
|
|
37
|
+
* - Setting up template mounting and caching
|
|
38
|
+
* - Defining global helpers (route, signedRoute, app, config)
|
|
39
|
+
* - Adding view getter to HttpContext for isolated rendering
|
|
40
|
+
* - Adding render macro to BriskRoute
|
|
41
|
+
* - Registering dumper plugin
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* await provider.boot()
|
|
45
|
+
* // Now edge templates can use {{ route('home') }} helper
|
|
46
|
+
*/
|
|
10
47
|
async boot() {
|
|
11
48
|
const app = this.app;
|
|
12
49
|
const qs = new main_exports.Qs(app.config.get("app.http.qs", {}));
|
|
13
50
|
const router = await this.app.container.make("router");
|
|
14
51
|
const dumper = await this.app.container.make("dumper");
|
|
52
|
+
/**
|
|
53
|
+
* Resolves configuration values for Edge templates
|
|
54
|
+
*
|
|
55
|
+
* Provides access to application configuration within templates.
|
|
56
|
+
* Includes a 'has' method to check for config key existence.
|
|
57
|
+
*
|
|
58
|
+
* @param key - The configuration key to retrieve
|
|
59
|
+
* @param defaultValue - Optional default value if key doesn't exist
|
|
60
|
+
*/
|
|
15
61
|
function edgeConfigResolver(key, defaultValue) {
|
|
16
62
|
return app.config.get(key, defaultValue);
|
|
17
63
|
}
|
|
18
64
|
edgeConfigResolver.has = function(key) {
|
|
19
65
|
return app.config.has(key);
|
|
20
66
|
};
|
|
67
|
+
/**
|
|
68
|
+
* Generates client-side route definitions for frontend use
|
|
69
|
+
*
|
|
70
|
+
* Transforms router definitions into a serializable format that
|
|
71
|
+
* can be used in client-side JavaScript for route generation.
|
|
72
|
+
* Only includes named routes.
|
|
73
|
+
*/
|
|
21
74
|
function clientRoutes() {
|
|
22
75
|
const routes = router.toJSON();
|
|
23
76
|
return Object.keys(routes).reduce((result, domain) => {
|
|
@@ -35,8 +88,18 @@ var EdgeServiceProvider = class {
|
|
|
35
88
|
return result;
|
|
36
89
|
}, {});
|
|
37
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Mount the default disk
|
|
93
|
+
*/
|
|
38
94
|
edge.mount(app.viewsPath());
|
|
95
|
+
/**
|
|
96
|
+
* Cache templates in production
|
|
97
|
+
*/
|
|
39
98
|
edge.configure({ cache: app.inProduction });
|
|
99
|
+
/**
|
|
100
|
+
* Define Edge global helpers
|
|
101
|
+
* @deprecated
|
|
102
|
+
*/
|
|
40
103
|
edge.global("route", function(...args) {
|
|
41
104
|
return router.makeUrl(...args);
|
|
42
105
|
});
|
|
@@ -51,19 +114,35 @@ var EdgeServiceProvider = class {
|
|
|
51
114
|
edge.global("routesJSON", function() {
|
|
52
115
|
return JSON.stringify(clientRoutes());
|
|
53
116
|
});
|
|
117
|
+
/**
|
|
118
|
+
* Route helpers
|
|
119
|
+
*/
|
|
54
120
|
edge.global("urlFor", function(...args) {
|
|
55
121
|
return router.urlBuilder.urlFor(...args);
|
|
56
122
|
});
|
|
57
123
|
edge.global("signedUrlFor", function(...args) {
|
|
58
124
|
return router.urlBuilder.signedUrlFor(...args);
|
|
59
125
|
});
|
|
126
|
+
/**
|
|
127
|
+
* Sharing qs parser with templates
|
|
128
|
+
*/
|
|
60
129
|
edge.global("qs", qs);
|
|
61
130
|
edge.global("formAttributes", function(route, params, options) {
|
|
62
131
|
const matchingRoute = router.findOrFail(route);
|
|
132
|
+
/**
|
|
133
|
+
* Normalize method and keep a reference to the original method
|
|
134
|
+
*/
|
|
63
135
|
options = options ?? {};
|
|
64
136
|
let method = matchingRoute.methods[0].toUpperCase();
|
|
65
137
|
const original = method;
|
|
138
|
+
/**
|
|
139
|
+
* In case of HEAD, we must use the GET method
|
|
140
|
+
*/
|
|
66
141
|
if (method === "HEAD") method = "GET";
|
|
142
|
+
/**
|
|
143
|
+
* If method if not GET and POST, then use the querystring _method
|
|
144
|
+
* to and force update the method to "POST"
|
|
145
|
+
*/
|
|
67
146
|
if (method !== "GET" && method !== "POST") {
|
|
68
147
|
method = "POST";
|
|
69
148
|
options = {
|
|
@@ -80,9 +159,16 @@ var EdgeServiceProvider = class {
|
|
|
80
159
|
method
|
|
81
160
|
};
|
|
82
161
|
});
|
|
162
|
+
/**
|
|
163
|
+
* Creating a isolated instance of edge renderer
|
|
164
|
+
*/
|
|
83
165
|
main_exports.HttpContext.getter("view", function() {
|
|
84
166
|
return edge.createRenderer().share({ request: this.request });
|
|
85
167
|
}, true);
|
|
168
|
+
/**
|
|
169
|
+
* Adding brisk route to render templates without an
|
|
170
|
+
* explicit handler
|
|
171
|
+
*/
|
|
86
172
|
main_exports.BriskRoute.macro("render", function(template, data) {
|
|
87
173
|
function rendersTemplate({ view }) {
|
|
88
174
|
return view.render(template, data);
|
|
@@ -96,4 +182,5 @@ var EdgeServiceProvider = class {
|
|
|
96
182
|
edge.use(pluginEdgeDumper(dumper));
|
|
97
183
|
}
|
|
98
184
|
};
|
|
185
|
+
//#endregion
|
|
99
186
|
export { EdgeServiceProvider as default };
|