@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.
Files changed (161) hide show
  1. package/build/ace-DBm6EcQ-.js +37 -0
  2. package/build/app-BCcG_oDd.js +7 -0
  3. package/build/app-CAuSGb2P.js +15 -0
  4. package/build/bodyparser_middleware-H5FArWkI.js +9 -0
  5. package/build/{chunk-iKc69rpz.js → chunk-Do49iUES.js} +3 -0
  6. package/build/commands/add.d.ts +1 -0
  7. package/build/commands/add.js +64 -10
  8. package/build/commands/build.js +41 -3
  9. package/build/commands/commands.json +1 -1
  10. package/build/commands/configure.js +70 -4
  11. package/build/commands/eject.js +30 -4
  12. package/build/commands/env/add.js +62 -4
  13. package/build/commands/generate_key.js +23 -3
  14. package/build/commands/inspect_rcfile.js +26 -2
  15. package/build/commands/list/routes.d.ts +5 -0
  16. package/build/commands/list/routes.js +242 -3
  17. package/build/commands/make/command.js +33 -4
  18. package/build/commands/make/controller.js +46 -4
  19. package/build/commands/make/event.js +36 -4
  20. package/build/commands/make/exception.js +36 -4
  21. package/build/commands/make/listener.js +44 -4
  22. package/build/commands/make/middleware.js +53 -5
  23. package/build/commands/make/preload.js +55 -5
  24. package/build/commands/make/provider.js +54 -5
  25. package/build/commands/make/service.js +29 -4
  26. package/build/commands/make/test.js +63 -4
  27. package/build/commands/make/transformer.js +37 -4
  28. package/build/commands/make/validator.js +44 -4
  29. package/build/commands/make/view.js +33 -4
  30. package/build/commands/repl.js +31 -2
  31. package/build/commands/serve.js +54 -4
  32. package/build/commands/test.js +69 -4
  33. package/build/config-Coti2q6R.js +7 -0
  34. package/build/config_provider-Do9af1ze.js +35 -0
  35. package/build/container-CGfEwWof.js +7 -0
  36. package/build/{core-IpCOCkUL.js → core-XjMm_ipu.js} +51 -2
  37. package/build/create_kernel-BV3swyCg.js +4 -0
  38. package/build/{create_kernel-B7ILNhuP.js → create_kernel-D38-0Zbt.js} +41 -1
  39. package/build/debug-DWofTfIX.js +20 -0
  40. package/build/{decorate-DmrZA614.js → decorate-B9Uz0anB.js} +2 -0
  41. package/build/{define_config-0oHaj43l.js → define_config--5euEdi8.js} +54 -3
  42. package/build/dumper-3R77st8F.js +353 -0
  43. package/build/edge-BG5ZYp6Z.js +57 -0
  44. package/build/{errors-CrCO-k44.js → errors-BScZTzBu.js} +9 -1
  45. package/build/events-DlKX1ZdL.js +7 -0
  46. package/build/exceptions-B2MzIlHY.js +2 -0
  47. package/build/factories/app.js +1 -0
  48. package/build/factories/bodyparser.js +1 -0
  49. package/build/factories/core/ace.js +16 -22
  50. package/build/factories/core/ignitor.js +13 -73
  51. package/build/factories/core/main.js +25 -17
  52. package/build/factories/core/test_utils.js +22 -19
  53. package/build/factories/encryption.js +1 -0
  54. package/build/factories/events.js +1 -0
  55. package/build/factories/hash.js +1 -0
  56. package/build/factories/http.js +1 -0
  57. package/build/factories/logger.js +1 -0
  58. package/build/factories/stubs.js +75 -7
  59. package/build/ignitor-Kym3gR-I.js +169 -0
  60. package/build/index.js +11 -8
  61. package/build/logger-DIdZPHCe.js +43 -0
  62. package/build/main-B50zECAi.js +121 -0
  63. package/build/main-CRnMnrH7.js +184 -0
  64. package/build/{main-kn40V-hF.js → main-CfTiGsiS.js} +2 -0
  65. package/build/main-Ck0GqLx4.js +117 -0
  66. package/build/main-CoZI4Ezs.js +2 -0
  67. package/build/main-D1MSq4Uu.js +435 -0
  68. package/build/{main--nXd7T-C.js → main-bRYXIHgD.js} +75 -3
  69. package/build/main-zxNP7iRl.js +7 -0
  70. package/build/modules/ace/codemods.js +301 -2
  71. package/build/modules/ace/commands.d.ts +5 -0
  72. package/build/modules/ace/main.js +2 -1
  73. package/build/modules/app.js +3 -5
  74. package/build/modules/bodyparser/bodyparser_middleware.js +2 -2
  75. package/build/modules/bodyparser/main.js +3 -5
  76. package/build/modules/config.js +3 -5
  77. package/build/modules/container.js +3 -5
  78. package/build/modules/dumper/main.js +29 -2
  79. package/build/modules/dumper/plugins/edge.js +2 -46
  80. package/build/modules/encryption/drivers/aes_256_cbc.js +1 -0
  81. package/build/modules/encryption/drivers/aes_256_gcm.js +1 -0
  82. package/build/modules/encryption/drivers/aes_siv.js +1 -0
  83. package/build/modules/encryption/drivers/chacha20_poly1305.js +1 -0
  84. package/build/modules/encryption/drivers/legacy.js +46 -1
  85. package/build/modules/encryption/main.js +7 -5
  86. package/build/modules/env/editor.js +1 -0
  87. package/build/modules/env/main.js +1 -0
  88. package/build/modules/events.js +3 -5
  89. package/build/modules/hash/drivers/argon.js +1 -0
  90. package/build/modules/hash/drivers/bcrypt.js +1 -0
  91. package/build/modules/hash/drivers/scrypt.js +1 -0
  92. package/build/modules/hash/main.js +4 -4
  93. package/build/modules/hash/phc_formatter.js +1 -0
  94. package/build/modules/health.js +1 -0
  95. package/build/modules/http/helpers.js +1 -0
  96. package/build/modules/http/main.js +2 -2
  97. package/build/modules/http/url_builder_client.js +1 -0
  98. package/build/modules/logger.js +3 -13
  99. package/build/modules/repl.js +3 -5
  100. package/build/modules/transformers/main.js +1 -0
  101. package/build/providers/app_provider.js +214 -15
  102. package/build/providers/edge_provider.js +90 -3
  103. package/build/providers/hash_provider.js +59 -4
  104. package/build/providers/repl_provider.js +64 -2
  105. package/build/providers/vinejs_provider.js +44 -3
  106. package/build/repl-C02Re0Yd.js +7 -0
  107. package/build/services/ace.js +11 -1
  108. package/build/services/app.js +2 -4
  109. package/build/services/config.js +7 -1
  110. package/build/services/dumper.js +13 -1
  111. package/build/services/emitter.js +8 -1
  112. package/build/services/encryption.js +8 -1
  113. package/build/services/hash.js +8 -1
  114. package/build/services/logger.js +8 -1
  115. package/build/services/repl.js +8 -1
  116. package/build/services/router.js +8 -1
  117. package/build/services/server.js +8 -1
  118. package/build/services/test_utils.js +11 -1
  119. package/build/services/url_builder.js +8 -1
  120. package/build/src/cli_formatters/routes_list.d.ts +7 -0
  121. package/build/src/exceptions.js +2 -1
  122. package/build/src/helpers/assert.js +1 -0
  123. package/build/src/helpers/http.js +1 -0
  124. package/build/src/helpers/is.js +24 -0
  125. package/build/src/helpers/main.js +2 -1
  126. package/build/src/helpers/string.js +2 -27
  127. package/build/src/helpers/types.js +18 -0
  128. package/build/src/helpers/verification_token.js +2 -45
  129. package/build/src/test_utils/main.js +9 -7
  130. package/build/src/types.js +1 -0
  131. package/build/src/vine.js +2 -32
  132. package/build/string-8_8He-HH.js +46 -0
  133. package/build/test_utils-DbJS_uEu.js +32 -0
  134. package/build/toolkit/main.js +13 -1
  135. package/build/types/ace.js +1 -0
  136. package/build/types/app.js +1 -0
  137. package/build/types/bodyparser.js +1 -0
  138. package/build/types/common.js +1 -0
  139. package/build/types/container.js +1 -0
  140. package/build/types/encryption.js +1 -0
  141. package/build/types/events.js +1 -0
  142. package/build/types/hash.js +1 -0
  143. package/build/types/health.js +1 -0
  144. package/build/types/helpers.js +1 -0
  145. package/build/types/http.js +1 -0
  146. package/build/types/logger.js +1 -0
  147. package/build/types/repl.js +1 -0
  148. package/build/types/transformers.js +1 -0
  149. package/build/utils-CKwka7OL.js +105 -0
  150. package/build/verification_token-WCrZtUgZ.js +108 -0
  151. package/build/vine-DkIupA3Z.js +97 -0
  152. package/package.json +12 -12
  153. package/build/config_provider-FIAUgvae.js +0 -13
  154. package/build/create_kernel-BD0Iqi8e.js +0 -3
  155. package/build/debug-CGQmxzGt.js +0 -3
  156. package/build/dumper-BBgqFX5a.js +0 -147
  157. package/build/main-Cxz0TyIw.js +0 -173
  158. package/build/main-DN2qEEg5.js +0 -41
  159. package/build/main-DkNgvceD.js +0 -52
  160. package/build/main-MBAMnmJb.js +0 -81
  161. package/build/utils-rRkbAPnP.js +0 -42
@@ -0,0 +1,435 @@
1
+ import { t as debug_default } from "./debug-DWofTfIX.js";
2
+ import { n as setApp } from "./app-CAuSGb2P.js";
3
+ import { t as app_exports } from "./app-BCcG_oDd.js";
4
+ import { createServer } from "node:http";
5
+ //#region src/ignitor/ace.ts
6
+ /**
7
+ * The Ace process is used to start the application in the
8
+ * console environment. It manages the Ace kernel lifecycle
9
+ * and command execution.
10
+ *
11
+ * @example
12
+ * const ignitor = new Ignitor()
13
+ * const aceProcess = new AceProcess(ignitor)
14
+ *
15
+ * await aceProcess
16
+ * .configure((app) => {
17
+ * // Configure ace kernel
18
+ * })
19
+ * .handle(['make:controller', 'UserController'])
20
+ */
21
+ var AceProcess = class {
22
+ /**
23
+ * Ignitor reference
24
+ */
25
+ #ignitor;
26
+ /**
27
+ * The callback that configures the ace instance before the
28
+ * handle method is called
29
+ */
30
+ #configureCallback = () => {};
31
+ /**
32
+ * Creates a new Ace process instance
33
+ *
34
+ * @param ignitor - The ignitor instance used to create and manage the app
35
+ */
36
+ constructor(ignitor) {
37
+ this.#ignitor = ignitor;
38
+ }
39
+ /**
40
+ * Register a callback that can be used to configure the ace
41
+ * kernel before the handle method is called
42
+ *
43
+ * @param callback - Configuration callback function
44
+ */
45
+ configure(callback) {
46
+ this.#configureCallback = callback;
47
+ return this;
48
+ }
49
+ /**
50
+ * Handles the command line arguments and executes
51
+ * the matching ace commands
52
+ *
53
+ * @param argv - Command line arguments array
54
+ */
55
+ async handle(argv) {
56
+ const app = this.#ignitor.createApp("console");
57
+ await app.init();
58
+ const { createAceKernel } = await import("./create_kernel-BV3swyCg.js");
59
+ const commandName = argv[argv.findIndex((value) => !value.startsWith("-"))];
60
+ const kernel = createAceKernel(app, commandName);
61
+ app.container.bindValue("ace", kernel);
62
+ /**
63
+ * Hook into kernel and start the app when the
64
+ * command needs the app.
65
+ *
66
+ * Since multiple commands can be executed in a single process,
67
+ * we add a check to only start the app only once.
68
+ */
69
+ kernel.loading(async (metaData) => {
70
+ if (metaData.options.startApp && !app.isReady) {
71
+ if (metaData.commandName === "repl") app.setEnvironment("repl");
72
+ await app.boot();
73
+ await app.start(() => {});
74
+ }
75
+ });
76
+ await this.#configureCallback(app);
77
+ /**
78
+ * Register terminating callback BEFORE handling the command.
79
+ * This ensures the callback is registered even if a staysAlive
80
+ * command calls app.terminate() during its execution.
81
+ */
82
+ app.terminating(() => {
83
+ const mainCommand = kernel.getMainCommand();
84
+ if (mainCommand?.staysAlive) process.exitCode = mainCommand.exitCode;
85
+ });
86
+ /**
87
+ * Handle command line args
88
+ */
89
+ await kernel.handle(argv);
90
+ /**
91
+ * Terminate the app when the command does not want to
92
+ * hold a long running process
93
+ */
94
+ const mainCommand = kernel.getMainCommand();
95
+ if (!mainCommand || !mainCommand.staysAlive) {
96
+ process.exitCode = kernel.exitCode;
97
+ await app.terminate();
98
+ }
99
+ }
100
+ };
101
+ //#endregion
102
+ //#region src/ignitor/test.ts
103
+ /**
104
+ * The Test runner process is used to start the tests runner process.
105
+ * It provides lifecycle hooks for configuring the test environment
106
+ * and running tests within the AdonisJS application context.
107
+ *
108
+ * @example
109
+ * const ignitor = new Ignitor()
110
+ * const testProcess = new TestRunnerProcess(ignitor)
111
+ *
112
+ * await testProcess
113
+ * .configure((app) => {
114
+ * // Configure test environment
115
+ * })
116
+ * .run(async (app) => {
117
+ * // Run your tests
118
+ * })
119
+ */
120
+ var TestRunnerProcess = class {
121
+ /**
122
+ * Ignitor reference
123
+ */
124
+ #ignitor;
125
+ /**
126
+ * The callback that configures the tests runner. This callback
127
+ * runs at the time of starting the app.
128
+ */
129
+ #configureCallback = () => {};
130
+ /**
131
+ * Creates a new test runner process instance
132
+ *
133
+ * @param ignitor - The ignitor instance used to create and manage the app
134
+ */
135
+ constructor(ignitor) {
136
+ this.#ignitor = ignitor;
137
+ }
138
+ /**
139
+ * Register a callback that runs after booting the AdonisJS app
140
+ * and just before the provider's ready hook
141
+ *
142
+ * @param callback - Configuration callback function
143
+ */
144
+ configure(callback) {
145
+ this.#configureCallback = callback;
146
+ return this;
147
+ }
148
+ /**
149
+ * Runs a callback after starting the app
150
+ *
151
+ * @param callback - Test execution callback function
152
+ */
153
+ async run(callback) {
154
+ const app = this.#ignitor.createApp("test");
155
+ await app.init();
156
+ await app.boot();
157
+ await app.start(this.#configureCallback);
158
+ await callback(app);
159
+ }
160
+ };
161
+ //#endregion
162
+ //#region src/ignitor/http.ts
163
+ /**
164
+ * The HTTP server process is used to start the application in the
165
+ * web environment. It creates and manages the Node.js HTTP server
166
+ * instance, handling lifecycle events and monitoring.
167
+ *
168
+ * @example
169
+ * const ignitor = new Ignitor()
170
+ * const httpProcess = new HttpServerProcess(ignitor)
171
+ * await httpProcess.start()
172
+ */
173
+ var HttpServerProcess = class {
174
+ /**
175
+ * Ignitor reference
176
+ */
177
+ #ignitor;
178
+ /**
179
+ * Creates a new HTTP server process instance
180
+ *
181
+ * @param ignitor - The ignitor instance used to create and manage the app
182
+ */
183
+ constructor(ignitor) {
184
+ this.#ignitor = ignitor;
185
+ }
186
+ /**
187
+ * Calling this method closes the underlying HTTP server gracefully.
188
+ *
189
+ * @param nodeHttpServer - The Node.js HTTP or HTTPS server instance to close
190
+ */
191
+ #close(nodeHttpServer) {
192
+ return new Promise((resolve) => {
193
+ debug_default("closing http server process");
194
+ nodeHttpServer.close(() => resolve());
195
+ });
196
+ }
197
+ /**
198
+ * Monitors the app and the server to close the HTTP server when
199
+ * either one of them goes down. Sets up event listeners for graceful shutdown.
200
+ *
201
+ * @param nodeHttpServer - The Node.js HTTP or HTTPS server instance to monitor
202
+ * @param app - The application service instance
203
+ * @param logger - The logger service for error reporting
204
+ */
205
+ #monitorAppAndServer(nodeHttpServer, app, logger) {
206
+ /**
207
+ * Close the HTTP server when the application begins to
208
+ * terminate
209
+ */
210
+ app.terminating(async () => {
211
+ debug_default("terminating signal received");
212
+ await this.#close(nodeHttpServer);
213
+ });
214
+ /**
215
+ * Terminate the app when the HTTP server crashes
216
+ */
217
+ nodeHttpServer.once("error", (error) => {
218
+ debug_default("http server crashed with error \"%O\"", error);
219
+ logger.fatal({ err: error }, error.message);
220
+ process.exitCode = 1;
221
+ app.terminate();
222
+ });
223
+ }
224
+ /**
225
+ * Starts the HTTP server on a given host and port using environment variables.
226
+ *
227
+ * @param nodeHttpServer - The Node.js HTTP or HTTPS server instance to start listening
228
+ */
229
+ #listen(nodeHttpServer) {
230
+ return new Promise((resolve, reject) => {
231
+ const host = process.env.HOST || "0.0.0.0";
232
+ const port = Number(process.env.PORT || "3333");
233
+ nodeHttpServer.listen(port, host);
234
+ nodeHttpServer.once("listening", () => {
235
+ debug_default("listening to http server, host :%s, port: %s", host, port);
236
+ resolve({
237
+ port,
238
+ host
239
+ });
240
+ });
241
+ nodeHttpServer.once("error", (error) => {
242
+ reject(error);
243
+ });
244
+ });
245
+ }
246
+ /**
247
+ * Notifies the app and the parent process that the HTTP server is ready.
248
+ * Sends notifications through multiple channels: parent process, logger, and event emitter.
249
+ *
250
+ * @param app - The application service instance for parent process notification
251
+ * @param logger - The logger service for console output
252
+ * @param emitter - The event emitter for app-level notifications
253
+ * @param payload - Server startup information including host, port, and duration
254
+ */
255
+ #notifyServerHasStarted(app, logger, emitter, payload) {
256
+ /**
257
+ * Notify parent process
258
+ */
259
+ app.notify({
260
+ isAdonisJS: true,
261
+ environment: "web",
262
+ ...payload
263
+ });
264
+ /**
265
+ * Visual notification
266
+ */
267
+ logger.info("started HTTP server on %s:%s", payload.host, payload.port);
268
+ /**
269
+ * Notify app
270
+ */
271
+ emitter.emit("http:server_ready", payload);
272
+ }
273
+ /**
274
+ * Start the HTTP server by wiring up the application
275
+ *
276
+ * @param serverCallback - Optional callback to create custom HTTP server instance
277
+ */
278
+ async start(serverCallback) {
279
+ const startTime = process.hrtime();
280
+ /**
281
+ * Method to create the HTTP server
282
+ */
283
+ const createHTTPServer = serverCallback || createServer;
284
+ const app = this.#ignitor.createApp("web");
285
+ await app.init();
286
+ await app.boot();
287
+ await app.start(async () => {
288
+ /**
289
+ * Resolve and boot the AdonisJS HTTP server
290
+ */
291
+ const server = await app.container.make("server");
292
+ await server.boot();
293
+ /**
294
+ * Create Node.js HTTP server instance and share it with the
295
+ * AdonisJS HTTP server
296
+ */
297
+ const httpServer = createHTTPServer(server.handle.bind(server));
298
+ server.setNodeServer(httpServer);
299
+ const logger = await app.container.make("logger");
300
+ const emitter = await app.container.make("emitter");
301
+ /**
302
+ * Start the server by listening on a port of host
303
+ */
304
+ const payload = await this.#listen(httpServer);
305
+ /**
306
+ * Notify
307
+ */
308
+ this.#notifyServerHasStarted(app, logger, emitter, {
309
+ ...payload,
310
+ duration: process.hrtime(startTime)
311
+ });
312
+ /**
313
+ * Monitor app and the server (after the server is listening)
314
+ */
315
+ this.#monitorAppAndServer(httpServer, app, logger);
316
+ });
317
+ }
318
+ };
319
+ //#endregion
320
+ //#region src/ignitor/main.ts
321
+ /**
322
+ * Ignitor is used to instantiate an AdonisJS application in different
323
+ * known environments. It serves as the main entry point for creating
324
+ * and managing application processes.
325
+ *
326
+ * @example
327
+ * const ignitor = new Ignitor(new URL(import.meta.url))
328
+ *
329
+ * // For HTTP server
330
+ * await ignitor.httpServer().start()
331
+ *
332
+ * // For CLI commands
333
+ * await ignitor.ace().handle(process.argv.slice(2))
334
+ *
335
+ * // For tests
336
+ * await ignitor.testRunner().run(() => {})
337
+ */
338
+ var Ignitor = class {
339
+ /**
340
+ * Ignitor options
341
+ */
342
+ #options;
343
+ /**
344
+ * Application root URL
345
+ */
346
+ #appRoot;
347
+ /**
348
+ * Reference to the application instance created using
349
+ * the "createApp" method.
350
+ *
351
+ * We store the output of the last call made to "createApp" method
352
+ * and assume that in one process only one entrypoint will
353
+ * call this method.
354
+ */
355
+ #app;
356
+ /**
357
+ * Reference to the created application
358
+ */
359
+ #tapCallbacks = /* @__PURE__ */ new Set();
360
+ /**
361
+ * Creates a new Ignitor instance
362
+ *
363
+ * @param appRoot - The root URL of the application
364
+ * @param options - Configuration options for the ignitor
365
+ */
366
+ constructor(appRoot, options = {}) {
367
+ this.#appRoot = appRoot;
368
+ this.#options = options;
369
+ }
370
+ /**
371
+ * Runs all the tap callbacks
372
+ */
373
+ #runTapCallbacks(app) {
374
+ this.#tapCallbacks.forEach((tapCallback) => tapCallback(app));
375
+ }
376
+ /**
377
+ * Get access to the application instance created
378
+ * by either the http server process or the ace
379
+ * process
380
+ */
381
+ getApp() {
382
+ return this.#app;
383
+ }
384
+ /**
385
+ * Create an instance of AdonisJS application
386
+ *
387
+ * @param environment - The environment in which to create the app (web, console, test, repl)
388
+ */
389
+ createApp(environment) {
390
+ debug_default("creating application instance");
391
+ this.#app = new app_exports.Application(this.#appRoot, {
392
+ environment,
393
+ importer: this.#options.importer
394
+ });
395
+ setApp(this.#app);
396
+ this.#runTapCallbacks(this.#app);
397
+ return this.#app;
398
+ }
399
+ /**
400
+ * Tap to access the application class instance.
401
+ *
402
+ * @param callback - Callback function to execute when app is created
403
+ */
404
+ tap(callback) {
405
+ this.#tapCallbacks.add(callback);
406
+ return this;
407
+ }
408
+ /**
409
+ * Get instance of the HTTPServerProcess
410
+ */
411
+ httpServer() {
412
+ return new HttpServerProcess(this);
413
+ }
414
+ /**
415
+ * Get an instance of the AceProcess class
416
+ */
417
+ ace() {
418
+ return new AceProcess(this);
419
+ }
420
+ /**
421
+ * Get an instance of the TestRunnerProcess class
422
+ */
423
+ testRunner() {
424
+ return new TestRunnerProcess(this);
425
+ }
426
+ /**
427
+ * Terminates the app by calling the "app.terminate"
428
+ * method
429
+ */
430
+ async terminate() {
431
+ await this.#app?.terminate();
432
+ }
433
+ };
434
+ //#endregion
435
+ export { Ignitor as t };
@@ -1,14 +1,41 @@
1
- import { t as debug_default } from "./debug-CGQmxzGt.js";
2
- import { t as main_exports } from "./main-DN2qEEg5.js";
3
- import { Encryption } from "./modules/encryption/main.js";
1
+ import { t as debug_default } from "./debug-DWofTfIX.js";
2
+ import { t as main_exports } from "./main-Ck0GqLx4.js";
3
+ import { n as Encryption } from "./main-CoZI4Ezs.js";
4
4
  import { IncomingMessage, ServerResponse, createServer } from "node:http";
5
5
  import { Socket } from "node:net";
6
6
  import Macroable from "@poppinss/macroable";
7
+ //#region src/test_utils/http.ts
8
+ /**
9
+ * Http server utils are used to start the AdonisJS HTTP server
10
+ * during testing. It provides methods to start and stop the server
11
+ * for integration testing.
12
+ *
13
+ * @example
14
+ * const testUtils = new TestUtils(app)
15
+ * const httpUtils = testUtils.httpServer()
16
+ *
17
+ * const closeServer = await httpUtils.start()
18
+ * // Make HTTP requests to test endpoints
19
+ * await closeServer() // Clean up
20
+ */
7
21
  var HttpServerUtils = class {
22
+ /**
23
+ * Reference to the test utils instance
24
+ */
8
25
  #utils;
26
+ /**
27
+ * Creates a new HttpServerUtils instance
28
+ *
29
+ * @param utils - The test utils instance
30
+ */
9
31
  constructor(utils) {
10
32
  this.#utils = utils;
11
33
  }
34
+ /**
35
+ * Starts the http server a given host and port
36
+ *
37
+ * @param nodeHttpServer - The Node.js HTTP server instance
38
+ */
12
39
  #listen(nodeHttpServer) {
13
40
  return new Promise((resolve, reject) => {
14
41
  const host = process.env.HOST || "0.0.0.0";
@@ -26,6 +53,12 @@ var HttpServerUtils = class {
26
53
  });
27
54
  });
28
55
  }
56
+ /**
57
+ * Testing hook to start the HTTP server to listen for new request.
58
+ * The return value is a function to close the HTTP server.
59
+ *
60
+ * @param serverCallback - Optional callback to create custom HTTP server instance
61
+ */
29
62
  async start(serverCallback) {
30
63
  const createHTTPServer = serverCallback || createServer;
31
64
  const server = await this.#utils.app.container.make("server");
@@ -43,24 +76,62 @@ var HttpServerUtils = class {
43
76
  };
44
77
  }
45
78
  };
79
+ //#endregion
80
+ //#region src/test_utils/main.ts
81
+ /**
82
+ * Test utils has a collection of helper methods to make testing
83
+ * experience great for AdonisJS applications. It provides utilities
84
+ * for HTTP testing, context creation, and cookie handling.
85
+ *
86
+ * @example
87
+ * const testUtils = new TestUtils(app)
88
+ * await testUtils.boot()
89
+ *
90
+ * const ctx = await testUtils.createHttpContext()
91
+ * const httpUtils = testUtils.httpServer()
92
+ */
46
93
  var TestUtils = class extends Macroable {
94
+ /**
95
+ * Flag to track if test utils have been booted
96
+ */
47
97
  #booted = false;
98
+ /**
99
+ * Check if utils have been booted
100
+ */
48
101
  get isBooted() {
49
102
  return this.#booted;
50
103
  }
104
+ /**
105
+ * Creates a new TestUtils instance
106
+ *
107
+ * @param app - The application service instance
108
+ */
51
109
  constructor(app) {
52
110
  super();
53
111
  this.app = app;
54
112
  }
113
+ /**
114
+ * Boot test utils. It requires the app to be booted
115
+ * and container to have all the bindings
116
+ */
55
117
  async boot() {
56
118
  if (!this.isBooted) {
57
119
  this.#booted = true;
58
120
  this.cookies = new main_exports.CookieClient(await this.app.container.make(Encryption));
59
121
  }
60
122
  }
123
+ /**
124
+ * Returns an instance of the HTTP server testing
125
+ * utils
126
+ */
61
127
  httpServer() {
62
128
  return new HttpServerUtils(this);
63
129
  }
130
+ /**
131
+ * Create an instance of HTTP context for testing
132
+ *
133
+ * @param options - Options for creating HTTP context with custom req/res objects
134
+ */
64
135
  async createHttpContext(options = {}) {
65
136
  const req = options.req || new IncomingMessage(new Socket());
66
137
  const res = options.res || new ServerResponse(req);
@@ -70,4 +141,5 @@ var TestUtils = class extends Macroable {
70
141
  return server.createHttpContext(request, response, this.app.container.createResolver());
71
142
  }
72
143
  };
144
+ //#endregion
73
145
  export { TestUtils as t };
@@ -0,0 +1,7 @@
1
+ import { n as __reExport, t as __exportAll } from "./chunk-Do49iUES.js";
2
+ //#region modules/bodyparser/main.ts
3
+ var main_exports = /* @__PURE__ */ __exportAll({});
4
+ import * as import__adonisjs_bodyparser from "@adonisjs/bodyparser";
5
+ __reExport(main_exports, import__adonisjs_bodyparser);
6
+ //#endregion
7
+ export { main_exports as t };