@adonisjs/core 7.0.0-next.1 → 7.0.0-next.10

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 (41) hide show
  1. package/build/commands/serve.js +3 -9
  2. package/build/commands/test.js +2 -8
  3. package/build/modules/ace/codemods.d.ts +109 -14
  4. package/build/modules/ace/codemods.js +119 -16
  5. package/build/modules/ace/main.d.ts +30 -0
  6. package/build/modules/ace/main.js +30 -0
  7. package/build/modules/app.d.ts +17 -0
  8. package/build/modules/app.js +17 -0
  9. package/build/modules/config.d.ts +17 -0
  10. package/build/modules/config.js +17 -0
  11. package/build/modules/dumper/dumper.d.ts +5 -0
  12. package/build/modules/dumper/dumper.js +11 -1
  13. package/build/modules/dumper/main.d.ts +21 -0
  14. package/build/modules/dumper/main.js +21 -0
  15. package/build/modules/encryption.d.ts +17 -0
  16. package/build/modules/encryption.js +17 -0
  17. package/build/modules/env/main.d.ts +19 -0
  18. package/build/modules/env/main.js +19 -0
  19. package/build/modules/hash/drivers/bcrypt.d.ts +11 -0
  20. package/build/modules/hash/drivers/bcrypt.js +11 -0
  21. package/build/modules/hash/main.d.ts +18 -0
  22. package/build/modules/hash/main.js +18 -0
  23. package/build/modules/http/url_builder_client.d.ts +1 -0
  24. package/build/modules/http/url_builder_client.js +9 -0
  25. package/build/providers/app_provider.d.ts +9 -21
  26. package/build/providers/app_provider.js +40 -44
  27. package/build/providers/edge_provider.js +62 -1
  28. package/build/src/assembler_hooks/index_entities.js +8 -2
  29. package/build/src/cli_formatters/routes_list.js +23 -7
  30. package/build/src/helpers/http.d.ts +20 -0
  31. package/build/src/helpers/http.js +28 -0
  32. package/build/src/helpers/main.d.ts +1 -5
  33. package/build/src/helpers/main.js +1 -5
  34. package/build/src/helpers/string.js +18 -0
  35. package/build/src/ignitor/http.js +18 -5
  36. package/build/src/types.d.ts +1 -0
  37. package/build/src/utils.d.ts +1 -1
  38. package/build/src/utils.js +13 -3
  39. package/build/src/vine.js +14 -6
  40. package/build/types/helpers.d.ts +20 -0
  41. package/package.json +22 -21
@@ -1 +1,18 @@
1
+ /**
2
+ * Encryption module re-exports all functionality from @adonisjs/encryption.
3
+ * This includes the Encryption class and related utilities for encrypting and
4
+ * decrypting data using various algorithms and key management strategies.
5
+ *
6
+ * @example
7
+ * // Import the Encryption class
8
+ * import { Encryption } from '@adonisjs/core/encryption'
9
+ *
10
+ * const encryption = new Encryption({ secret: 'your-secret-key' })
11
+ * const encrypted = encryption.encrypt('sensitive data')
12
+ * const decrypted = encryption.decrypt(encrypted)
13
+ *
14
+ * @example
15
+ * // Import encryption types and utilities
16
+ * import type { EncryptionConfig, DriverContract } from '@adonisjs/core/encryption'
17
+ */
1
18
  export * from '@adonisjs/encryption';
@@ -6,4 +6,21 @@
6
6
  * For the full copyright and license information, please view the LICENSE
7
7
  * file that was distributed with this source code.
8
8
  */
9
+ /**
10
+ * Encryption module re-exports all functionality from @adonisjs/encryption.
11
+ * This includes the Encryption class and related utilities for encrypting and
12
+ * decrypting data using various algorithms and key management strategies.
13
+ *
14
+ * @example
15
+ * // Import the Encryption class
16
+ * import { Encryption } from '@adonisjs/core/encryption'
17
+ *
18
+ * const encryption = new Encryption({ secret: 'your-secret-key' })
19
+ * const encrypted = encryption.encrypt('sensitive data')
20
+ * const decrypted = encryption.decrypt(encrypted)
21
+ *
22
+ * @example
23
+ * // Import encryption types and utilities
24
+ * import type { EncryptionConfig, DriverContract } from '@adonisjs/core/encryption'
25
+ */
9
26
  export * from '@adonisjs/encryption';
@@ -1 +1,20 @@
1
+ /**
2
+ * Environment module re-exports all functionality from @adonisjs/env.
3
+ * This includes the Env class, validation schemas, and utilities for managing
4
+ * environment variables with type safety and validation.
5
+ *
6
+ * @example
7
+ * // Import the Env class and validation
8
+ * import { Env } from '@adonisjs/core/env'
9
+ *
10
+ * const env = await Env.create(new URL('../', import.meta.url), {
11
+ * NODE_ENV: Env.schema.enum(['development', 'production', 'test'] as const),
12
+ * PORT: Env.schema.number(),
13
+ * HOST: Env.schema.string({ format: 'host' })
14
+ * })
15
+ *
16
+ * @example
17
+ * // Import environment types and utilities
18
+ * import type { EnvParser, EnvEditor } from '@adonisjs/core/env'
19
+ */
1
20
  export * from '@adonisjs/env';
@@ -6,4 +6,23 @@
6
6
  * For the full copyright and license information, please view the LICENSE
7
7
  * file that was distributed with this source code.
8
8
  */
9
+ /**
10
+ * Environment module re-exports all functionality from @adonisjs/env.
11
+ * This includes the Env class, validation schemas, and utilities for managing
12
+ * environment variables with type safety and validation.
13
+ *
14
+ * @example
15
+ * // Import the Env class and validation
16
+ * import { Env } from '@adonisjs/core/env'
17
+ *
18
+ * const env = await Env.create(new URL('../', import.meta.url), {
19
+ * NODE_ENV: Env.schema.enum(['development', 'production', 'test'] as const),
20
+ * PORT: Env.schema.number(),
21
+ * HOST: Env.schema.string({ format: 'host' })
22
+ * })
23
+ *
24
+ * @example
25
+ * // Import environment types and utilities
26
+ * import type { EnvParser, EnvEditor } from '@adonisjs/core/env'
27
+ */
9
28
  export * from '@adonisjs/env';
@@ -1 +1,12 @@
1
+ /**
2
+ * Bcrypt hash driver re-exports from @adonisjs/hash.
3
+ * Provides bcrypt password hashing functionality with configurable rounds.
4
+ *
5
+ * @example
6
+ * import { Bcrypt } from '@adonisjs/core/hash/drivers/bcrypt'
7
+ *
8
+ * const bcrypt = new Bcrypt({ rounds: 12 })
9
+ * const hashed = await bcrypt.make('password')
10
+ * const isValid = await bcrypt.verify(hashed, 'password')
11
+ */
1
12
  export * from '@adonisjs/hash/drivers/bcrypt';
@@ -6,4 +6,15 @@
6
6
  * For the full copyright and license information, please view the LICENSE
7
7
  * file that was distributed with this source code.
8
8
  */
9
+ /**
10
+ * Bcrypt hash driver re-exports from @adonisjs/hash.
11
+ * Provides bcrypt password hashing functionality with configurable rounds.
12
+ *
13
+ * @example
14
+ * import { Bcrypt } from '@adonisjs/core/hash/drivers/bcrypt'
15
+ *
16
+ * const bcrypt = new Bcrypt({ rounds: 12 })
17
+ * const hashed = await bcrypt.make('password')
18
+ * const isValid = await bcrypt.verify(hashed, 'password')
19
+ */
9
20
  export * from '@adonisjs/hash/drivers/bcrypt';
@@ -1,2 +1,20 @@
1
+ /**
2
+ * Hash module provides password hashing functionality with multiple driver support.
3
+ * Re-exports all functionality from @adonisjs/hash along with configuration utilities.
4
+ *
5
+ * @example
6
+ * // Import the Hash manager and drivers
7
+ * import { HashManager, Hash } from '@adonisjs/core/hash'
8
+ *
9
+ * const manager = new HashManager(config)
10
+ * const hasher = manager.use('scrypt')
11
+ * const hashed = await hasher.make('password')
12
+ * const verified = await hasher.verify(hashed, 'password')
13
+ *
14
+ * @example
15
+ * // Import configuration and driver types
16
+ * import { defineConfig, drivers } from '@adonisjs/core/hash'
17
+ * import type { HashConfig, ScryptConfig } from '@adonisjs/core/types/hash'
18
+ */
1
19
  export * from '@adonisjs/hash';
2
20
  export { defineConfig, drivers } from './define_config.ts';
@@ -6,5 +6,23 @@
6
6
  * For the full copyright and license information, please view the LICENSE
7
7
  * file that was distributed with this source code.
8
8
  */
9
+ /**
10
+ * Hash module provides password hashing functionality with multiple driver support.
11
+ * Re-exports all functionality from @adonisjs/hash along with configuration utilities.
12
+ *
13
+ * @example
14
+ * // Import the Hash manager and drivers
15
+ * import { HashManager, Hash } from '@adonisjs/core/hash'
16
+ *
17
+ * const manager = new HashManager(config)
18
+ * const hasher = manager.use('scrypt')
19
+ * const hashed = await hasher.make('password')
20
+ * const verified = await hasher.verify(hashed, 'password')
21
+ *
22
+ * @example
23
+ * // Import configuration and driver types
24
+ * import { defineConfig, drivers } from '@adonisjs/core/hash'
25
+ * import type { HashConfig, ScryptConfig } from '@adonisjs/core/types/hash'
26
+ */
9
27
  export * from '@adonisjs/hash';
10
28
  export { defineConfig, drivers } from "./define_config.js";
@@ -0,0 +1 @@
1
+ export * from '@adonisjs/http-server/client/url_builder';
@@ -0,0 +1,9 @@
1
+ /*
2
+ * @adonisjs/core
3
+ *
4
+ * (c) AdonisJS
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+ export * from '@adonisjs/http-server/client/url_builder';
@@ -174,32 +174,20 @@ export default class AppServiceProvider {
174
174
  */
175
175
  protected registerDumper(): void;
176
176
  /**
177
- * Generates the types needed by the URL builder and writes
178
- * them to the ".adonisjs/server/routes.d.ts" file
177
+ * Generates TypeScript type definitions and JSON representation of routes
179
178
  *
180
- * This method scans registered routes and generates TypeScript
181
- * types for type-safe URL generation in development.
179
+ * Creates route type definitions for better IDE support and a JSON file
180
+ * containing all registered routes. This is used in development mode for
181
+ * tooling integration and type-safety.
182
182
  *
183
- * @param router - The router instance to generate types from
183
+ * @param router - The router instance containing registered routes
184
184
  *
185
185
  * @example
186
- * await generateRoutesTypes(router)
187
- * // Creates .adonisjs/server/routes.d.ts with route types
188
- */
189
- protected generateRoutesTypes(router: Router): Promise<void>;
190
- /**
191
- * Generates the routes JSON needed by the client integration
192
- *
193
- * Exports all registered routes as JSON for client-side
194
- * applications that need route information.
195
- *
196
- * @param router - The router instance to export routes from
197
- *
198
- * @example
199
- * await generateRoutesJSONFile(router)
200
- * // Creates .adonisjs/client/routes.json
186
+ * const router = await container.make('router')
187
+ * await this.emitRoutes(router)
188
+ * // Generates .adonisjs/server/routes.d.ts and routes.json
201
189
  */
202
- protected generateRoutesJSONFile(router: Router): Promise<void>;
190
+ protected emitRoutes(router: Router): Promise<void>;
203
191
  /**
204
192
  * Registers bindings
205
193
  *
@@ -225,7 +225,7 @@ export default class AppServiceProvider {
225
225
  * await middleware.handle(ctx, next)
226
226
  */
227
227
  registerBodyParserMiddleware() {
228
- this.app.container.bind(BodyParserMiddleware, () => {
228
+ this.app.container.singleton(BodyParserMiddleware, () => {
229
229
  const config = this.app.config.get('bodyparser');
230
230
  return new BodyParserMiddleware(config, this.app.experimentalFlags);
231
231
  });
@@ -256,50 +256,47 @@ export default class AppServiceProvider {
256
256
  this.app.container.alias('dumper', Dumper);
257
257
  }
258
258
  /**
259
- * Generates the types needed by the URL builder and writes
260
- * them to the ".adonisjs/server/routes.d.ts" file
259
+ * Generates TypeScript type definitions and JSON representation of routes
261
260
  *
262
- * This method scans registered routes and generates TypeScript
263
- * types for type-safe URL generation in development.
261
+ * Creates route type definitions for better IDE support and a JSON file
262
+ * containing all registered routes. This is used in development mode for
263
+ * tooling integration and type-safety.
264
264
  *
265
- * @param router - The router instance to generate types from
265
+ * @param router - The router instance containing registered routes
266
266
  *
267
267
  * @example
268
- * await generateRoutesTypes(router)
269
- * // Creates .adonisjs/server/routes.d.ts with route types
270
- */
271
- async generateRoutesTypes(router) {
272
- const types = router.generateTypes(4);
273
- const outputPath = this.app.generatedServerPath('routes.d.ts');
274
- await mkdir(dirname(outputPath), { recursive: true });
275
- await writeFile(outputPath, [
276
- `import '@adonisjs/core/types/http'`,
277
- '',
278
- `declare module '@adonisjs/core/types/http' {`,
279
- ' type ScannedRoutes = {',
280
- types,
281
- ' }',
282
- 'export interface RoutesList extends ScannedRoutes {}',
283
- '}',
284
- ].join('\n'));
285
- }
286
- /**
287
- * Generates the routes JSON needed by the client integration
288
- *
289
- * Exports all registered routes as JSON for client-side
290
- * applications that need route information.
291
- *
292
- * @param router - The router instance to export routes from
293
- *
294
- * @example
295
- * await generateRoutesJSONFile(router)
296
- * // Creates .adonisjs/client/routes.json
268
+ * const router = await container.make('router')
269
+ * await this.emitRoutes(router)
270
+ * // Generates .adonisjs/server/routes.d.ts and routes.json
297
271
  */
298
- async generateRoutesJSONFile(router) {
299
- const routes = router.toJSON();
300
- const outputPath = this.app.makePath('.adonisjs/client/routes.json');
301
- await mkdir(dirname(outputPath), { recursive: true });
302
- await writeFile(outputPath, JSON.stringify(routes, null, 2));
272
+ async emitRoutes(router) {
273
+ try {
274
+ const { routes, imports, types } = router.generateTypes(2);
275
+ const routesTypesPath = this.app.generatedServerPath('routes.d.ts');
276
+ const routesJsonPath = this.app.generatedServerPath('routes.json');
277
+ await mkdir(dirname(routesTypesPath), { recursive: true });
278
+ await Promise.all([
279
+ writeFile(routesTypesPath, [
280
+ `import '@adonisjs/core/types/http'`,
281
+ ...imports,
282
+ '',
283
+ ...types,
284
+ '',
285
+ 'export type ScannedRoutes = {',
286
+ routes,
287
+ '}',
288
+ `declare module '@adonisjs/core/types/http' {`,
289
+ ' export interface RoutesList extends ScannedRoutes {}',
290
+ '}',
291
+ ].join('\n')),
292
+ writeFile(routesJsonPath, JSON.stringify(router.toJSON())),
293
+ ]);
294
+ this.app.notify({ isAdonisJS: true, routesFileLocation: routesJsonPath });
295
+ }
296
+ catch (error) {
297
+ console.error("Unable to generate routes types file due to the following error. This won't impact the dev-server");
298
+ console.error(error);
299
+ }
303
300
  }
304
301
  /**
305
302
  * Registers bindings
@@ -337,8 +334,8 @@ export default class AppServiceProvider {
337
334
  */
338
335
  async boot() {
339
336
  BaseEvent.useEmitter(await this.app.container.make('emitter'));
340
- HttpContext.instanceProperty('serialize', function (...args) {
341
- return serialize(...args);
337
+ HttpContext.instanceProperty('serialize', function (value, container) {
338
+ return serialize(value, container ?? this.containerResolver);
342
339
  });
343
340
  }
344
341
  /**
@@ -355,8 +352,7 @@ export default class AppServiceProvider {
355
352
  if (!this.app.inProduction) {
356
353
  const router = await this.app.container.make('router');
357
354
  if (router.commited) {
358
- await this.generateRoutesJSONFile(router);
359
- await this.generateRoutesTypes(router);
355
+ await this.emitRoutes(router);
360
356
  }
361
357
  }
362
358
  }
@@ -8,7 +8,7 @@
8
8
  */
9
9
  import edge from 'edge.js';
10
10
  import { pluginEdgeDumper } from "../modules/dumper/plugins/edge.js";
11
- import { BriskRoute, HttpContext } from "../modules/http/main.js";
11
+ import { BriskRoute, HttpContext, Qs } from "../modules/http/main.js";
12
12
  /**
13
13
  * The Edge service provider configures Edge to work within
14
14
  * an AdonisJS application environment
@@ -53,6 +53,7 @@ export default class EdgeServiceProvider {
53
53
  */
54
54
  async boot() {
55
55
  const app = this.app;
56
+ const qs = new Qs(app.config.get('app.http.qs', {}));
56
57
  const router = await this.app.container.make('router');
57
58
  const dumper = await this.app.container.make('dumper');
58
59
  function edgeConfigResolver(key, defaultValue) {
@@ -61,6 +62,25 @@ export default class EdgeServiceProvider {
61
62
  edgeConfigResolver.has = function (key) {
62
63
  return app.config.has(key);
63
64
  };
65
+ function clientRoutes() {
66
+ const routes = router.toJSON();
67
+ return Object.keys(routes).reduce((result, domain) => {
68
+ result[domain] = routes[domain].reduce((routesResult, route) => {
69
+ if (!route.name) {
70
+ return routesResult;
71
+ }
72
+ routesResult.push({
73
+ domain: route.domain,
74
+ methods: route.methods,
75
+ pattern: route.pattern,
76
+ tokens: route.tokens,
77
+ name: route.name,
78
+ });
79
+ return routesResult;
80
+ }, []);
81
+ return result;
82
+ }, {});
83
+ }
64
84
  /**
65
85
  * Mount the default disk
66
86
  */
@@ -71,6 +91,7 @@ export default class EdgeServiceProvider {
71
91
  edge.configure({ cache: app.inProduction });
72
92
  /**
73
93
  * Define Edge global helpers
94
+ * @deprecated
74
95
  */
75
96
  edge.global('route', function (...args) {
76
97
  return router.makeUrl(...args);
@@ -80,6 +101,46 @@ export default class EdgeServiceProvider {
80
101
  });
81
102
  edge.global('app', app);
82
103
  edge.global('config', edgeConfigResolver);
104
+ edge.global('routes', function () {
105
+ return clientRoutes();
106
+ });
107
+ edge.global('routesJSON', function () {
108
+ return JSON.stringify(clientRoutes());
109
+ });
110
+ /**
111
+ * Route helpers
112
+ */
113
+ edge.global('urlFor', function (...args) {
114
+ return router.urlBuilder.urlFor(...args);
115
+ });
116
+ edge.global('signedUrlFor', function (...args) {
117
+ return router.urlBuilder.signedUrlFor(...args);
118
+ });
119
+ /**
120
+ * Sharing qs parser with templates
121
+ */
122
+ edge.global('qs', qs);
123
+ edge.global('formAttributes', function (route, method, params, options) {
124
+ /**
125
+ * Normalize method and keep a reference to the original method
126
+ */
127
+ options = options ?? {};
128
+ method = method.toUpperCase();
129
+ const original = method;
130
+ /**
131
+ * If method if not GET and POST, then use the querystring _method
132
+ * to and force update the method to "POST"
133
+ */
134
+ if (method !== 'GET' && method !== 'POST') {
135
+ method = 'POST';
136
+ options = { ...options, qs: { _method: original, ...options.qs } };
137
+ }
138
+ const { action } = router.urlBuilder.urlFor.method(original, route, params, options).form;
139
+ return {
140
+ action,
141
+ method,
142
+ };
143
+ });
83
144
  /**
84
145
  * Creating a isolated instance of edge renderer
85
146
  */
@@ -45,12 +45,18 @@ export function indexEntities(entities = {}) {
45
45
  const events = Object.assign({ enabled: true, source: 'app/events', importAlias: '#events' }, entities.events);
46
46
  const listeners = Object.assign({ enabled: true, source: 'app/listeners', importAlias: '#listeners' }, entities.listeners);
47
47
  const controllers = Object.assign({ enabled: true, source: 'app/controllers', importAlias: '#controllers' }, entities.controllers);
48
- const transformers = Object.assign({ enabled: false, source: 'app/transformers', importAlias: '#transformers' }, entities.transformers);
48
+ const transformers = Object.assign({
49
+ enabled: false,
50
+ source: 'app/transformers',
51
+ importAlias: '#transformers',
52
+ withSharedProps: false,
53
+ }, entities.transformers);
49
54
  return {
50
55
  run(_, indexGenerator) {
51
56
  if (events.enabled) {
52
57
  indexGenerator.add('events', {
53
58
  source: events.source,
59
+ disableLazyImports: true,
54
60
  glob: events.glob,
55
61
  as: 'barrelFile',
56
62
  exportName: 'events',
@@ -95,7 +101,7 @@ export function indexEntities(entities = {}) {
95
101
  },
96
102
  transformValue: helpers.toImportPath,
97
103
  });
98
- outputTransformerDataObjects(transformersList, buffer);
104
+ outputTransformerDataObjects(transformersList, buffer, transformers.withSharedProps);
99
105
  },
100
106
  importAlias: transformers.importAlias,
101
107
  output: '.adonisjs/client/data.d.ts',
@@ -64,7 +64,9 @@ export class RoutesListFormatter {
64
64
  this.#router.commit();
65
65
  }
66
66
  /**
67
- * Test if a route clears the applied filters
67
+ * Test if a route clears the applied filters based on middleware, name, pattern, and handler.
68
+ *
69
+ * @param route - The serialized route to test against filters
68
70
  */
69
71
  #isAllowedByFilters(route) {
70
72
  let allowRoute = true;
@@ -124,7 +126,10 @@ export class RoutesListFormatter {
124
126
  return false;
125
127
  }
126
128
  /**
127
- * Serializes routes JSON to an object that can be used for pretty printing
129
+ * Serializes routes JSON to an object that can be used for pretty printing.
130
+ * Converts RouteJSON into a format suitable for display and filtering.
131
+ *
132
+ * @param route - The route JSON object to serialize
128
133
  */
129
134
  async #serializeRoute(route) {
130
135
  let methods = route.methods;
@@ -143,13 +148,17 @@ export class RoutesListFormatter {
143
148
  };
144
149
  }
145
150
  /**
146
- * Formats the route method for the ansi list and table
151
+ * Formats the route method for the ansi list and table with dim styling.
152
+ *
153
+ * @param method - The HTTP method to format (GET, POST, etc.)
147
154
  */
148
155
  #formatRouteMethod(method) {
149
156
  return this.#colors.dim(method);
150
157
  }
151
158
  /**
152
- * Formats route pattern for the ansi list and table
159
+ * Formats route pattern for the ansi list and table with colored parameters and route name.
160
+ *
161
+ * @param route - The serialized route containing pattern and name information
153
162
  */
154
163
  #formatRoutePattern(route) {
155
164
  const pattern = this.#router
@@ -170,7 +179,9 @@ export class RoutesListFormatter {
170
179
  return `${pattern === '/' ? pattern : `/${pattern}`}${route.name ? ` ${this.#colors.dim(`(${route.name})`)}` : ''} `;
171
180
  }
172
181
  /**
173
- * Formats controller name for the ansi list and table
182
+ * Formats controller name for the ansi list and table with cyan coloring.
183
+ *
184
+ * @param route - The serialized route containing handler information
174
185
  */
175
186
  #formatControllerName(route) {
176
187
  return route.handler.type === 'controller'
@@ -178,7 +189,9 @@ export class RoutesListFormatter {
178
189
  : '';
179
190
  }
180
191
  /**
181
- * Formats action name for the ansi list and table
192
+ * Formats action name for the ansi list and table with cyan coloring and arguments.
193
+ *
194
+ * @param route - The serialized route containing handler information
182
195
  */
183
196
  #formatAction(route) {
184
197
  if (route.handler.type === 'controller') {
@@ -191,7 +204,10 @@ export class RoutesListFormatter {
191
204
  return functionName;
192
205
  }
193
206
  /**
194
- * Formats route middleware for the ansi list and table
207
+ * Formats route middleware for the ansi list and table with optional compacting.
208
+ *
209
+ * @param route - The serialized route containing middleware information
210
+ * @param mode - Display mode: 'normal' shows all middleware, 'compact' truncates long lists
195
211
  */
196
212
  #formatMiddleware(route, mode = 'normal') {
197
213
  if (mode === 'compact' && route.middleware.length > 3) {
@@ -0,0 +1,20 @@
1
+ /**
2
+ * HTTP helper utilities re-exported from @adonisjs/http-server. This module
3
+ * provides a convenient entry point for accessing all HTTP-related utilities
4
+ * including route helpers, middleware utilities, and request/response helpers.
5
+ *
6
+ * @example
7
+ * // Import specific HTTP helpers
8
+ * import { middlewareInfo, routeInfo } from '@adonisjs/core/helpers'
9
+ *
10
+ * const middleware = middlewareInfo('cors', CorsMiddleware)
11
+ * const route = routeInfo('users.show', '/users/:id')
12
+ *
13
+ * @example
14
+ * // Access all HTTP helpers
15
+ * import * as httpHelpers from '@adonisjs/core/helpers/http'
16
+ *
17
+ * // Use any helper from the http-server package
18
+ * const routeData = httpHelpers.routeInfo('api.posts', '/api/posts')
19
+ */
20
+ export * from '@adonisjs/http-server/helpers';
@@ -0,0 +1,28 @@
1
+ /*
2
+ * @adonisjs/core
3
+ *
4
+ * (c) AdonisJS
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+ /**
10
+ * HTTP helper utilities re-exported from @adonisjs/http-server. This module
11
+ * provides a convenient entry point for accessing all HTTP-related utilities
12
+ * including route helpers, middleware utilities, and request/response helpers.
13
+ *
14
+ * @example
15
+ * // Import specific HTTP helpers
16
+ * import { middlewareInfo, routeInfo } from '@adonisjs/core/helpers'
17
+ *
18
+ * const middleware = middlewareInfo('cors', CorsMiddleware)
19
+ * const route = routeInfo('users.show', '/users/:id')
20
+ *
21
+ * @example
22
+ * // Access all HTTP helpers
23
+ * import * as httpHelpers from '@adonisjs/core/helpers/http'
24
+ *
25
+ * // Use any helper from the http-server package
26
+ * const routeData = httpHelpers.routeInfo('api.posts', '/api/posts')
27
+ */
28
+ export * from '@adonisjs/http-server/helpers';
@@ -37,12 +37,8 @@ export { default as base64 } from '@poppinss/utils/base64';
37
37
  * Core utilities including function composition, secret management,
38
38
  * safe equality comparison, and message building.
39
39
  */
40
- export { compose, Secret, safeEqual, MessageBuilder } from '@poppinss/utils';
40
+ export { compose, Secret, safeEqual, MessageBuilder, defineStaticProperty } from '@poppinss/utils';
41
41
  /**
42
42
  * Verification token utility for creating secure tokens.
43
43
  */
44
44
  export { VerificationToken } from './verification_token.ts';
45
- /**
46
- * HTTP server helper functions for middleware and route information.
47
- */
48
- export { middlewareInfo, routeInfo } from '@adonisjs/http-server/helpers';
@@ -45,12 +45,8 @@ export { default as base64 } from '@poppinss/utils/base64';
45
45
  * Core utilities including function composition, secret management,
46
46
  * safe equality comparison, and message building.
47
47
  */
48
- export { compose, Secret, safeEqual, MessageBuilder } from '@poppinss/utils';
48
+ export { compose, Secret, safeEqual, MessageBuilder, defineStaticProperty } from '@poppinss/utils';
49
49
  /**
50
50
  * Verification token utility for creating secure tokens.
51
51
  */
52
52
  export { VerificationToken } from "./verification_token.js";
53
- /**
54
- * HTTP server helper functions for middleware and route information.
55
- */
56
- export { middlewareInfo, routeInfo } from '@adonisjs/http-server/helpers';
@@ -43,9 +43,21 @@ const stringHelpers = {
43
43
  prettyHrTime(time, options) {
44
44
  return prettyHrTime(time, options);
45
45
  },
46
+ /**
47
+ * Check if a string is empty or contains only whitespace characters.
48
+ *
49
+ * @param value - The string to check for emptiness
50
+ */
46
51
  isEmpty(value) {
47
52
  return value.trim().length === 0;
48
53
  },
54
+ /**
55
+ * Escape HTML entities to prevent XSS attacks and display HTML safely.
56
+ *
57
+ * @param value - The string containing HTML to escape
58
+ * @param options - Optional configuration for escaping behavior
59
+ * @param options.encodeSymbols - Whether to also encode Unicode symbols as HTML entities
60
+ */
49
61
  escapeHTML(value, options) {
50
62
  value = he.escape(value);
51
63
  if (options && options.encodeSymbols) {
@@ -53,6 +65,12 @@ const stringHelpers = {
53
65
  }
54
66
  return value;
55
67
  },
68
+ /**
69
+ * Encode Unicode symbols and special characters as HTML entities.
70
+ *
71
+ * @param value - The string containing symbols to encode
72
+ * @param options - Encoding options from the 'he' library
73
+ */
56
74
  encodeSymbols(value, options) {
57
75
  return he.encode(value, options);
58
76
  },