@adonisjs/core 7.0.0-next.4 → 7.0.0-next.6
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/modules/ace/codemods.d.ts +109 -14
- package/build/modules/ace/codemods.js +109 -14
- package/build/modules/ace/main.d.ts +30 -0
- package/build/modules/ace/main.js +30 -0
- package/build/modules/app.d.ts +17 -0
- package/build/modules/app.js +17 -0
- package/build/modules/config.d.ts +17 -0
- package/build/modules/config.js +17 -0
- package/build/modules/dumper/dumper.d.ts +5 -0
- package/build/modules/dumper/dumper.js +11 -1
- package/build/modules/dumper/main.d.ts +21 -0
- package/build/modules/dumper/main.js +21 -0
- package/build/modules/encryption.d.ts +17 -0
- package/build/modules/encryption.js +17 -0
- package/build/modules/env/main.d.ts +19 -0
- package/build/modules/env/main.js +19 -0
- package/build/modules/hash/drivers/bcrypt.d.ts +11 -0
- package/build/modules/hash/drivers/bcrypt.js +11 -0
- package/build/modules/hash/main.d.ts +18 -0
- package/build/modules/hash/main.js +18 -0
- package/build/providers/app_provider.d.ts +0 -13
- package/build/providers/app_provider.js +20 -32
- package/build/providers/edge_provider.js +52 -1
- package/build/src/cli_formatters/routes_list.js +23 -7
- package/build/src/helpers/http.d.ts +20 -0
- package/build/src/helpers/http.js +28 -0
- package/build/src/helpers/main.d.ts +0 -4
- package/build/src/helpers/main.js +0 -4
- package/build/src/helpers/string.js +18 -0
- package/build/src/ignitor/http.js +18 -5
- package/build/src/vine.js +14 -6
- package/build/types/helpers.d.ts +20 -0
- package/package.json +14 -14
|
@@ -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";
|
|
@@ -187,19 +187,6 @@ export default class AppServiceProvider {
|
|
|
187
187
|
* // Creates .adonisjs/server/routes.d.ts with route types
|
|
188
188
|
*/
|
|
189
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
|
|
201
|
-
*/
|
|
202
|
-
protected generateRoutesJSONFile(router: Router): Promise<void>;
|
|
203
190
|
/**
|
|
204
191
|
* Registers bindings
|
|
205
192
|
*
|
|
@@ -269,37 +269,25 @@ export default class AppServiceProvider {
|
|
|
269
269
|
* // Creates .adonisjs/server/routes.d.ts with route types
|
|
270
270
|
*/
|
|
271
271
|
async generateRoutesTypes(router) {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
*
|
|
292
|
-
* @param router - The router instance to export routes from
|
|
293
|
-
*
|
|
294
|
-
* @example
|
|
295
|
-
* await generateRoutesJSONFile(router)
|
|
296
|
-
* // Creates .adonisjs/client/routes.json
|
|
297
|
-
*/
|
|
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
|
+
try {
|
|
273
|
+
const types = router.generateTypes(2);
|
|
274
|
+
const outputPath = this.app.generatedServerPath('routes.d.ts');
|
|
275
|
+
await mkdir(dirname(outputPath), { recursive: true });
|
|
276
|
+
await writeFile(outputPath, [
|
|
277
|
+
`import '@adonisjs/core/types/http'`,
|
|
278
|
+
'',
|
|
279
|
+
'export type ScannedRoutes = {',
|
|
280
|
+
types,
|
|
281
|
+
'}',
|
|
282
|
+
`declare module '@adonisjs/core/types/http' {`,
|
|
283
|
+
' export interface RoutesList extends ScannedRoutes {}',
|
|
284
|
+
'}',
|
|
285
|
+
].join('\n'));
|
|
286
|
+
}
|
|
287
|
+
catch (error) {
|
|
288
|
+
console.error("Unable to generate routes types file due to the following error. This won't impact the dev-server");
|
|
289
|
+
console.error(error);
|
|
290
|
+
}
|
|
303
291
|
}
|
|
304
292
|
/**
|
|
305
293
|
* Registers bindings
|
|
@@ -355,8 +343,8 @@ export default class AppServiceProvider {
|
|
|
355
343
|
if (!this.app.inProduction) {
|
|
356
344
|
const router = await this.app.container.make('router');
|
|
357
345
|
if (router.commited) {
|
|
358
|
-
await this.generateRoutesJSONFile(router);
|
|
359
346
|
await this.generateRoutesTypes(router);
|
|
347
|
+
this.app.notify({ isAdonisJS: true, routes: JSON.stringify(router.toJSON()) });
|
|
360
348
|
}
|
|
361
349
|
}
|
|
362
350
|
}
|
|
@@ -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
|
*/
|
|
@@ -81,6 +101,12 @@ export default class EdgeServiceProvider {
|
|
|
81
101
|
});
|
|
82
102
|
edge.global('app', app);
|
|
83
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
|
+
});
|
|
84
110
|
/**
|
|
85
111
|
* Route helpers
|
|
86
112
|
*/
|
|
@@ -90,6 +116,31 @@ export default class EdgeServiceProvider {
|
|
|
90
116
|
edge.global('signedUrlFor', function (...args) {
|
|
91
117
|
return router.urlBuilder.signedUrlFor(...args);
|
|
92
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
|
+
});
|
|
93
144
|
/**
|
|
94
145
|
* Creating a isolated instance of edge renderer
|
|
95
146
|
*/
|
|
@@ -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';
|
|
@@ -42,7 +42,3 @@ export { compose, Secret, safeEqual, MessageBuilder, defineStaticProperty } from
|
|
|
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';
|
|
@@ -50,7 +50,3 @@ export { compose, Secret, safeEqual, MessageBuilder, defineStaticProperty } from
|
|
|
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
|
},
|
|
@@ -32,7 +32,9 @@ export class HttpServerProcess {
|
|
|
32
32
|
this.#ignitor = ignitor;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
|
-
* Calling this method closes the underlying HTTP server
|
|
35
|
+
* Calling this method closes the underlying HTTP server gracefully.
|
|
36
|
+
*
|
|
37
|
+
* @param nodeHttpServer - The Node.js HTTP or HTTPS server instance to close
|
|
36
38
|
*/
|
|
37
39
|
#close(nodeHttpServer) {
|
|
38
40
|
return new Promise((resolve) => {
|
|
@@ -42,7 +44,11 @@ export class HttpServerProcess {
|
|
|
42
44
|
}
|
|
43
45
|
/**
|
|
44
46
|
* Monitors the app and the server to close the HTTP server when
|
|
45
|
-
* either one of them goes down
|
|
47
|
+
* either one of them goes down. Sets up event listeners for graceful shutdown.
|
|
48
|
+
*
|
|
49
|
+
* @param nodeHttpServer - The Node.js HTTP or HTTPS server instance to monitor
|
|
50
|
+
* @param app - The application service instance
|
|
51
|
+
* @param logger - The logger service for error reporting
|
|
46
52
|
*/
|
|
47
53
|
#monitorAppAndServer(nodeHttpServer, app, logger) {
|
|
48
54
|
/**
|
|
@@ -64,7 +70,9 @@ export class HttpServerProcess {
|
|
|
64
70
|
});
|
|
65
71
|
}
|
|
66
72
|
/**
|
|
67
|
-
* Starts the
|
|
73
|
+
* Starts the HTTP server on a given host and port using environment variables.
|
|
74
|
+
*
|
|
75
|
+
* @param nodeHttpServer - The Node.js HTTP or HTTPS server instance to start listening
|
|
68
76
|
*/
|
|
69
77
|
#listen(nodeHttpServer) {
|
|
70
78
|
return new Promise((resolve, reject) => {
|
|
@@ -81,8 +89,13 @@ export class HttpServerProcess {
|
|
|
81
89
|
});
|
|
82
90
|
}
|
|
83
91
|
/**
|
|
84
|
-
* Notifies the app and the parent process that the
|
|
85
|
-
*
|
|
92
|
+
* Notifies the app and the parent process that the HTTP server is ready.
|
|
93
|
+
* Sends notifications through multiple channels: parent process, logger, and event emitter.
|
|
94
|
+
*
|
|
95
|
+
* @param app - The application service instance for parent process notification
|
|
96
|
+
* @param logger - The logger service for console output
|
|
97
|
+
* @param emitter - The event emitter for app-level notifications
|
|
98
|
+
* @param payload - Server startup information including host, port, and duration
|
|
86
99
|
*/
|
|
87
100
|
#notifyServerHasStarted(app, logger, emitter, payload) {
|
|
88
101
|
/**
|
package/build/src/vine.js
CHANGED
|
@@ -9,15 +9,21 @@
|
|
|
9
9
|
import vine, { symbols, BaseLiteralType } from '@vinejs/vine';
|
|
10
10
|
const MULTIPART_FILE = symbols.SUBTYPE ?? Symbol.for('subtype');
|
|
11
11
|
/**
|
|
12
|
-
* Checks if the value is an instance of multipart file
|
|
13
|
-
*
|
|
12
|
+
* Checks if the value is an instance of multipart file from bodyparser.
|
|
13
|
+
* Used internally for type guarding in file validation.
|
|
14
|
+
*
|
|
15
|
+
* @param file - The value to check for MultipartFile instance
|
|
14
16
|
*/
|
|
15
17
|
function isBodyParserFile(file) {
|
|
16
18
|
return !!(file && typeof file === 'object' && 'isMultipartFile' in file);
|
|
17
19
|
}
|
|
18
20
|
/**
|
|
19
|
-
* VineJS validation rule that validates the file to be an
|
|
20
|
-
*
|
|
21
|
+
* VineJS validation rule that validates the file to be an instance of BodyParser
|
|
22
|
+
* MultipartFile class and applies size/extension validation if configured.
|
|
23
|
+
*
|
|
24
|
+
* @param file - The file value to validate
|
|
25
|
+
* @param options - Validation options for file size and extensions
|
|
26
|
+
* @param field - The field context from VineJS validation
|
|
21
27
|
*/
|
|
22
28
|
const isMultipartFile = vine.createRule((file, options, field) => {
|
|
23
29
|
/**
|
|
@@ -26,7 +32,7 @@ const isMultipartFile = vine.createRule((file, options, field) => {
|
|
|
26
32
|
*/
|
|
27
33
|
if (!isBodyParserFile(file)) {
|
|
28
34
|
field.report('The {{ field }} must be a file', 'file', field);
|
|
29
|
-
return;
|
|
35
|
+
return false;
|
|
30
36
|
}
|
|
31
37
|
const validationOptions = typeof options === 'function' ? options(field) : options;
|
|
32
38
|
/**
|
|
@@ -53,6 +59,7 @@ const isMultipartFile = vine.createRule((file, options, field) => {
|
|
|
53
59
|
file.errors.forEach((error) => {
|
|
54
60
|
field.report(error.message, `file.${error.type}`, field, validationOptions);
|
|
55
61
|
});
|
|
62
|
+
return file.isValid;
|
|
56
63
|
});
|
|
57
64
|
/**
|
|
58
65
|
* Represents a multipart file uploaded via multipart/form-data HTTP
|
|
@@ -84,8 +91,9 @@ export class VineMultipartFile extends BaseLiteralType {
|
|
|
84
91
|
* @param validations - Array of validation functions to apply
|
|
85
92
|
*/
|
|
86
93
|
constructor(validationOptions, options, validations) {
|
|
87
|
-
super(options, validations || [
|
|
94
|
+
super(options, validations || []);
|
|
88
95
|
this.#validationOptions = validationOptions;
|
|
96
|
+
this.dataTypeValidator = isMultipartFile(validationOptions || {});
|
|
89
97
|
}
|
|
90
98
|
/**
|
|
91
99
|
* Creates a clone of the current VineMultipartFile instance
|
package/build/types/helpers.d.ts
CHANGED
|
@@ -1,2 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper types and utilities for AdonisJS applications.
|
|
3
|
+
* Re-exports commonly used type utilities and file system operation types.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* // Use Opaque type for branded primitives
|
|
7
|
+
* import type { Opaque } from '@adonisjs/core/types/helpers'
|
|
8
|
+
*
|
|
9
|
+
* type UserId = Opaque<'UserId', number>
|
|
10
|
+
* const userId: UserId = 123 as UserId
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // Use file system option types
|
|
14
|
+
* import type { ImportAllFilesOptions } from '@adonisjs/core/types/helpers'
|
|
15
|
+
*
|
|
16
|
+
* const options: ImportAllFilesOptions = {
|
|
17
|
+
* ignoreMissingExports: true,
|
|
18
|
+
* transformKeys: (key) => key.toLowerCase()
|
|
19
|
+
* }
|
|
20
|
+
*/
|
|
1
21
|
export type { Opaque, NormalizeConstructor } from '@poppinss/utils/types';
|
|
2
22
|
export type { ImportAllFilesOptions, ReadAllFilesOptions } from '@poppinss/utils/fs';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/core",
|
|
3
3
|
"description": "Core of AdonisJS",
|
|
4
|
-
"version": "7.0.0-next.
|
|
4
|
+
"version": "7.0.0-next.6",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=24.0.0"
|
|
7
7
|
},
|
|
@@ -84,10 +84,10 @@
|
|
|
84
84
|
"index:commands": "node --import=@poppinss/ts-exec toolkit/main.js index build/commands"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
|
-
"@adonisjs/assembler": "^8.0.0-next.
|
|
88
|
-
"@adonisjs/eslint-config": "^3.0.0-next.
|
|
87
|
+
"@adonisjs/assembler": "^8.0.0-next.14",
|
|
88
|
+
"@adonisjs/eslint-config": "^3.0.0-next.4",
|
|
89
89
|
"@adonisjs/prettier-config": "^1.4.5",
|
|
90
|
-
"@adonisjs/tsconfig": "^2.0.0-next.
|
|
90
|
+
"@adonisjs/tsconfig": "^2.0.0-next.2",
|
|
91
91
|
"@japa/assert": "^4.1.1",
|
|
92
92
|
"@japa/expect-type": "^2.0.3",
|
|
93
93
|
"@japa/file-system": "^2.3.2",
|
|
@@ -95,20 +95,20 @@
|
|
|
95
95
|
"@japa/snapshot": "^2.0.9",
|
|
96
96
|
"@poppinss/ts-exec": "^1.4.1",
|
|
97
97
|
"@release-it/conventional-changelog": "^10.0.1",
|
|
98
|
-
"@types/node": "^24.
|
|
98
|
+
"@types/node": "^24.7.2",
|
|
99
99
|
"@types/pretty-hrtime": "^1.0.3",
|
|
100
100
|
"@types/sinon": "^17.0.4",
|
|
101
101
|
"@types/supertest": "^6.0.3",
|
|
102
102
|
"@types/test-console": "^2.0.3",
|
|
103
|
-
"@vinejs/vine": "^
|
|
103
|
+
"@vinejs/vine": "^4.0.0-next.1",
|
|
104
104
|
"argon2": "^0.44.0",
|
|
105
105
|
"bcrypt": "^6.0.0",
|
|
106
106
|
"c8": "^10.1.3",
|
|
107
107
|
"copyfiles": "^2.4.1",
|
|
108
|
-
"cross-env": "^10.
|
|
108
|
+
"cross-env": "^10.1.0",
|
|
109
109
|
"del-cli": "^7.0.0",
|
|
110
110
|
"edge.js": "^6.3.0",
|
|
111
|
-
"eslint": "^9.
|
|
111
|
+
"eslint": "^9.37.0",
|
|
112
112
|
"execa": "^9.6.0",
|
|
113
113
|
"get-port": "^7.1.0",
|
|
114
114
|
"prettier": "^3.6.2",
|
|
@@ -117,12 +117,12 @@
|
|
|
117
117
|
"supertest": "^7.1.4",
|
|
118
118
|
"test-console": "^2.0.0",
|
|
119
119
|
"timekeeper": "^2.3.1",
|
|
120
|
-
"typedoc": "^0.28.
|
|
121
|
-
"typescript": "^5.9.
|
|
120
|
+
"typedoc": "^0.28.14",
|
|
121
|
+
"typescript": "^5.9.3",
|
|
122
122
|
"youch": "^4.1.0-beta.11"
|
|
123
123
|
},
|
|
124
124
|
"dependencies": {
|
|
125
|
-
"@adonisjs/ace": "^14.0.1-next.
|
|
125
|
+
"@adonisjs/ace": "^14.0.1-next.2",
|
|
126
126
|
"@adonisjs/application": "^9.0.0-next.9",
|
|
127
127
|
"@adonisjs/bodyparser": "^11.0.0-next.1",
|
|
128
128
|
"@adonisjs/config": "^6.0.0-next.1",
|
|
@@ -132,8 +132,8 @@
|
|
|
132
132
|
"@adonisjs/fold": "^11.0.0-next.2",
|
|
133
133
|
"@adonisjs/hash": "^10.0.0-next.1",
|
|
134
134
|
"@adonisjs/health": "^3.0.0-next.0",
|
|
135
|
-
"@adonisjs/http-server": "^8.0.0-next.
|
|
136
|
-
"@adonisjs/http-transformers": "^1.
|
|
135
|
+
"@adonisjs/http-server": "^8.0.0-next.11",
|
|
136
|
+
"@adonisjs/http-transformers": "^1.5.0",
|
|
137
137
|
"@adonisjs/logger": "^7.1.0-next.0",
|
|
138
138
|
"@adonisjs/repl": "^5.0.0-next.0",
|
|
139
139
|
"@poppinss/colors": "^4.1.5",
|
|
@@ -149,7 +149,7 @@
|
|
|
149
149
|
},
|
|
150
150
|
"peerDependencies": {
|
|
151
151
|
"@adonisjs/assembler": "^8.0.0-next.10",
|
|
152
|
-
"@vinejs/vine": "^
|
|
152
|
+
"@vinejs/vine": "^4.0.0-next.0",
|
|
153
153
|
"argon2": "^0.43.0",
|
|
154
154
|
"bcrypt": "^6.0.0",
|
|
155
155
|
"edge.js": "^6.2.0",
|