@adonisjs/core 7.0.0-next.4 → 7.0.0-next.5
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/providers/app_provider.d.ts +0 -13
- package/build/providers/app_provider.js +27 -32
- package/build/providers/edge_provider.js +52 -1
- package/build/src/helpers/http.d.ts +1 -0
- package/build/src/helpers/http.js +9 -0
- package/build/src/helpers/main.d.ts +0 -4
- package/build/src/helpers/main.js +0 -4
- package/package.json +7 -7
|
@@ -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,15 @@ 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
|
+
process.once('message', (message) => {
|
|
348
|
+
if (message &&
|
|
349
|
+
typeof message === 'object' &&
|
|
350
|
+
'purpose' in message &&
|
|
351
|
+
message.purpose === 'shareRoutes') {
|
|
352
|
+
this.app.notify({ isAdonisJS: true, routes: router.toJSON() });
|
|
353
|
+
}
|
|
354
|
+
});
|
|
360
355
|
}
|
|
361
356
|
}
|
|
362
357
|
}
|
|
@@ -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
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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';
|
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.5",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=24.0.0"
|
|
7
7
|
},
|
|
@@ -95,7 +95,7 @@
|
|
|
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.0",
|
|
99
99
|
"@types/pretty-hrtime": "^1.0.3",
|
|
100
100
|
"@types/sinon": "^17.0.4",
|
|
101
101
|
"@types/supertest": "^6.0.3",
|
|
@@ -105,10 +105,10 @@
|
|
|
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",
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"test-console": "^2.0.0",
|
|
119
119
|
"timekeeper": "^2.3.1",
|
|
120
120
|
"typedoc": "^0.28.13",
|
|
121
|
-
"typescript": "^5.9.
|
|
121
|
+
"typescript": "^5.9.3",
|
|
122
122
|
"youch": "^4.1.0-beta.11"
|
|
123
123
|
},
|
|
124
124
|
"dependencies": {
|
|
@@ -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.10",
|
|
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",
|