@adonisjs/http-server 8.0.0-next.12 → 8.0.0-next.14
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/define_config-Dh5SpqNg.js +2446 -0
- package/build/factories/http_context.d.ts +4 -4
- package/build/factories/main.d.ts +2 -2
- package/build/factories/main.js +163 -347
- package/build/factories/request.d.ts +4 -4
- package/build/factories/response.d.ts +4 -4
- package/build/factories/router.d.ts +1 -1
- package/build/factories/server_factory.d.ts +1 -1
- package/build/factories/url_builder_factory.d.ts +1 -1
- package/build/helpers-C_2HouOe.js +52 -0
- package/build/helpers-oKG4uNSM.js +686 -0
- package/build/index.d.ts +2 -2
- package/build/index.js +157 -375
- package/build/src/client/url_builder.js +3 -12
- package/build/src/cookies/client.d.ts +1 -1
- package/build/src/cookies/drivers/encrypted.d.ts +1 -1
- package/build/src/cookies/drivers/signed.d.ts +1 -1
- package/build/src/cookies/parser.d.ts +1 -1
- package/build/src/cookies/serializer.d.ts +1 -1
- package/build/src/debug.d.ts +1 -1
- package/build/src/exception_handler.d.ts +7 -0
- package/build/src/helpers.d.ts +1 -1
- package/build/src/helpers.js +3 -26
- package/build/src/http_context/main.d.ts +7 -7
- package/build/src/qs.d.ts +1 -1
- package/build/src/redirect.d.ts +2 -2
- package/build/src/request.d.ts +2 -2
- package/build/src/response.d.ts +5 -5
- package/build/src/router/main.d.ts +1 -1
- package/build/src/router/signed_url_builder.d.ts +1 -1
- package/build/src/server/main.d.ts +6 -6
- package/build/src/types/main.js +1 -0
- package/build/src/types/response.d.ts +6 -1
- package/build/url_builder-piNQy-CF.js +114 -0
- package/package.json +24 -22
- package/build/chunk-2QM3D5BN.js +0 -87
- package/build/chunk-77CSRFCU.js +0 -131
- package/build/chunk-L2UOVWDK.js +0 -4441
- package/build/chunk-QDK57QGB.js +0 -1176
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Logger } from '@adonisjs/logger';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
2
|
+
import type { HttpRequest } from '../src/request.ts';
|
|
3
|
+
import type { HttpResponse } from '../src/response.ts';
|
|
4
4
|
import { HttpContext } from '../src/http_context/main.ts';
|
|
5
5
|
type FactoryParameters = {
|
|
6
|
-
request:
|
|
7
|
-
response:
|
|
6
|
+
request: HttpRequest;
|
|
7
|
+
response: HttpResponse;
|
|
8
8
|
logger: Logger;
|
|
9
9
|
};
|
|
10
10
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { RouterFactory } from './router.ts';
|
|
2
|
-
export { RequestFactory } from './request.ts';
|
|
3
|
-
export { ResponseFactory } from './response.ts';
|
|
2
|
+
export { HttpRequestFactory as RequestFactory } from './request.ts';
|
|
3
|
+
export { HttpResponseFactory as ResponseFactory } from './response.ts';
|
|
4
4
|
export { ServerFactory } from './server_factory.ts';
|
|
5
5
|
export { HttpContextFactory } from './http_context.ts';
|
|
6
6
|
export { QsParserFactory } from './qs_parser_factory.ts';
|
package/build/factories/main.js
CHANGED
|
@@ -1,358 +1,174 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} from "../chunk-L2UOVWDK.js";
|
|
10
|
-
import "../chunk-QDK57QGB.js";
|
|
11
|
-
import "../chunk-77CSRFCU.js";
|
|
12
|
-
import "../chunk-2QM3D5BN.js";
|
|
13
|
-
|
|
14
|
-
// factories/router.ts
|
|
1
|
+
import "../helpers-oKG4uNSM.js";
|
|
2
|
+
import { _ as Qs, c as HttpRequest, i as HttpResponse, n as Server, r as HttpContext, s as Router, t as defineConfig } from "../define_config-Dh5SpqNg.js";
|
|
3
|
+
import "../helpers-C_2HouOe.js";
|
|
4
|
+
import "../url_builder-piNQy-CF.js";
|
|
5
|
+
import { Container } from "@adonisjs/fold";
|
|
6
|
+
import { Socket } from "node:net";
|
|
7
|
+
import proxyAddr from "proxy-addr";
|
|
8
|
+
import { safeStringify } from "@poppinss/utils/json";
|
|
15
9
|
import { AppFactory } from "@adonisjs/application/factories";
|
|
16
|
-
import { EncryptionFactory } from "@
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
import { EncryptionFactory } from "@boringnode/encryption/factories";
|
|
11
|
+
import { randomUUID } from "node:crypto";
|
|
12
|
+
import { IncomingMessage, ServerResponse } from "node:http";
|
|
13
|
+
import { Logger } from "@adonisjs/logger";
|
|
14
|
+
import { Emitter } from "@adonisjs/events";
|
|
15
|
+
import { LoggerFactory } from "@adonisjs/logger/factories";
|
|
19
16
|
var QsParserFactory = class {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
Object.assign(this.#options.parse, options.parse);
|
|
44
|
-
Object.assign(this.#options.stringify, options.stringify);
|
|
45
|
-
return this;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Create instance of the QS parser class
|
|
49
|
-
*/
|
|
50
|
-
create() {
|
|
51
|
-
return new Qs(this.#options);
|
|
52
|
-
}
|
|
17
|
+
#options = {
|
|
18
|
+
parse: {
|
|
19
|
+
depth: 5,
|
|
20
|
+
parameterLimit: 1e3,
|
|
21
|
+
allowSparse: false,
|
|
22
|
+
arrayLimit: 20,
|
|
23
|
+
comma: true
|
|
24
|
+
},
|
|
25
|
+
stringify: {
|
|
26
|
+
encode: true,
|
|
27
|
+
encodeValuesOnly: false,
|
|
28
|
+
arrayFormat: "indices",
|
|
29
|
+
skipNulls: false
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
merge(options) {
|
|
33
|
+
Object.assign(this.#options.parse, options.parse);
|
|
34
|
+
Object.assign(this.#options.stringify, options.stringify);
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
create() {
|
|
38
|
+
return new Qs(this.#options);
|
|
39
|
+
}
|
|
53
40
|
};
|
|
54
|
-
|
|
55
|
-
// factories/router.ts
|
|
56
41
|
var RouterFactory = class {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
#createEncryption() {
|
|
72
|
-
return this.#parameters.encryption || new EncryptionFactory().create();
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Merge factory params
|
|
76
|
-
* @param params - Partial factory parameters to merge
|
|
77
|
-
*/
|
|
78
|
-
merge(params) {
|
|
79
|
-
Object.assign(this.#parameters, params);
|
|
80
|
-
return this;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Create router instance
|
|
84
|
-
*/
|
|
85
|
-
create() {
|
|
86
|
-
return new Router(this.#getApp(), this.#createEncryption(), new QsParserFactory().create());
|
|
87
|
-
}
|
|
42
|
+
#parameters = {};
|
|
43
|
+
#getApp() {
|
|
44
|
+
return this.#parameters.app || new AppFactory().create(new URL("./app/", import.meta.url));
|
|
45
|
+
}
|
|
46
|
+
#createEncryption() {
|
|
47
|
+
return this.#parameters.encryption || new EncryptionFactory().create();
|
|
48
|
+
}
|
|
49
|
+
merge(params) {
|
|
50
|
+
Object.assign(this.#parameters, params);
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
create() {
|
|
54
|
+
return new Router(this.#getApp(), this.#createEncryption(), new QsParserFactory().create());
|
|
55
|
+
}
|
|
88
56
|
};
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
if (this.#parameters.method) {
|
|
125
|
-
req.method = this.#parameters.method;
|
|
126
|
-
}
|
|
127
|
-
return req;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Returns the HTTP res object
|
|
131
|
-
* @param req - The incoming message request object
|
|
132
|
-
*/
|
|
133
|
-
#createResponse(req) {
|
|
134
|
-
return this.#parameters.res || new ServerResponse(req);
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Returns an instance of the encryptor to encrypt
|
|
138
|
-
* signed URLs
|
|
139
|
-
*/
|
|
140
|
-
#createEncryption() {
|
|
141
|
-
return this.#parameters.encryption || new EncryptionFactory2().create();
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Merge factory params
|
|
145
|
-
* @param params - Partial factory parameters to merge
|
|
146
|
-
*/
|
|
147
|
-
merge(params) {
|
|
148
|
-
Object.assign(this.#parameters, params);
|
|
149
|
-
return this;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Create request
|
|
153
|
-
*/
|
|
154
|
-
create() {
|
|
155
|
-
const req = this.#createRequest();
|
|
156
|
-
return new Request(
|
|
157
|
-
req,
|
|
158
|
-
this.#createResponse(req),
|
|
159
|
-
this.#createEncryption(),
|
|
160
|
-
this.#getConfig(),
|
|
161
|
-
new QsParserFactory().create()
|
|
162
|
-
);
|
|
163
|
-
}
|
|
57
|
+
var HttpRequestFactory = class {
|
|
58
|
+
#parameters = {};
|
|
59
|
+
#getConfig() {
|
|
60
|
+
return {
|
|
61
|
+
allowMethodSpoofing: false,
|
|
62
|
+
trustProxy: proxyAddr.compile("loopback"),
|
|
63
|
+
subdomainOffset: 2,
|
|
64
|
+
generateRequestId: false,
|
|
65
|
+
createRequestId() {
|
|
66
|
+
return randomUUID();
|
|
67
|
+
},
|
|
68
|
+
...this.#parameters.config
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
#createRequest() {
|
|
72
|
+
const req = this.#parameters.req || new IncomingMessage(new Socket());
|
|
73
|
+
if (this.#parameters.url) req.url = this.#parameters.url;
|
|
74
|
+
if (this.#parameters.method) req.method = this.#parameters.method;
|
|
75
|
+
return req;
|
|
76
|
+
}
|
|
77
|
+
#createResponse(req) {
|
|
78
|
+
return this.#parameters.res || new ServerResponse(req);
|
|
79
|
+
}
|
|
80
|
+
#createEncryption() {
|
|
81
|
+
return this.#parameters.encryption || new EncryptionFactory().create();
|
|
82
|
+
}
|
|
83
|
+
merge(params) {
|
|
84
|
+
Object.assign(this.#parameters, params);
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
create() {
|
|
88
|
+
const req = this.#createRequest();
|
|
89
|
+
return new HttpRequest(req, this.#createResponse(req), this.#createEncryption(), this.#getConfig(), new QsParserFactory().create());
|
|
90
|
+
}
|
|
164
91
|
};
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
return this.#parameters.router || new RouterFactory().create();
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Returns the HTTP res object
|
|
206
|
-
* @param req - The incoming message request object
|
|
207
|
-
*/
|
|
208
|
-
#createResponse(req) {
|
|
209
|
-
return this.#parameters.res || new ServerResponse2(req);
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Returns an instance of the encryptor to encrypt
|
|
213
|
-
* signed URLs
|
|
214
|
-
*/
|
|
215
|
-
#createEncryption() {
|
|
216
|
-
return this.#parameters.encryption || new EncryptionFactory3().create();
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Merge factory params
|
|
220
|
-
* @param params - Partial factory parameters to merge
|
|
221
|
-
*/
|
|
222
|
-
merge(params) {
|
|
223
|
-
Object.assign(this.#parameters, params);
|
|
224
|
-
return this;
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Create response class instance
|
|
228
|
-
*/
|
|
229
|
-
create() {
|
|
230
|
-
const req = this.#createRequest();
|
|
231
|
-
return new Response(
|
|
232
|
-
req,
|
|
233
|
-
this.#createResponse(req),
|
|
234
|
-
this.#createEncryption(),
|
|
235
|
-
this.#getConfig(),
|
|
236
|
-
this.#createRouter(),
|
|
237
|
-
new QsParserFactory().create()
|
|
238
|
-
);
|
|
239
|
-
}
|
|
92
|
+
var HttpResponseFactory = class {
|
|
93
|
+
#parameters = {};
|
|
94
|
+
#getConfig() {
|
|
95
|
+
return {
|
|
96
|
+
etag: false,
|
|
97
|
+
serializeJSON: safeStringify,
|
|
98
|
+
jsonpCallbackName: "callback",
|
|
99
|
+
cookie: {
|
|
100
|
+
maxAge: 90,
|
|
101
|
+
path: "/",
|
|
102
|
+
httpOnly: true,
|
|
103
|
+
sameSite: false,
|
|
104
|
+
secure: false
|
|
105
|
+
},
|
|
106
|
+
...this.#parameters.config
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
#createRequest() {
|
|
110
|
+
return this.#parameters.req || new IncomingMessage(new Socket());
|
|
111
|
+
}
|
|
112
|
+
#createRouter() {
|
|
113
|
+
return this.#parameters.router || new RouterFactory().create();
|
|
114
|
+
}
|
|
115
|
+
#createResponse(req) {
|
|
116
|
+
return this.#parameters.res || new ServerResponse(req);
|
|
117
|
+
}
|
|
118
|
+
#createEncryption() {
|
|
119
|
+
return this.#parameters.encryption || new EncryptionFactory().create();
|
|
120
|
+
}
|
|
121
|
+
merge(params) {
|
|
122
|
+
Object.assign(this.#parameters, params);
|
|
123
|
+
return this;
|
|
124
|
+
}
|
|
125
|
+
create() {
|
|
126
|
+
const req = this.#createRequest();
|
|
127
|
+
return new HttpResponse(req, this.#createResponse(req), this.#createEncryption(), this.#getConfig(), this.#createRouter(), new QsParserFactory().create());
|
|
128
|
+
}
|
|
240
129
|
};
|
|
241
|
-
|
|
242
|
-
// factories/server_factory.ts
|
|
243
|
-
import { Logger } from "@adonisjs/logger";
|
|
244
|
-
import { Emitter } from "@adonisjs/events";
|
|
245
|
-
import { AppFactory as AppFactory2 } from "@adonisjs/application/factories";
|
|
246
|
-
import { EncryptionFactory as EncryptionFactory4 } from "@adonisjs/encryption/factories";
|
|
247
130
|
var ServerFactory = class {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
* Returns an instance of the application class
|
|
272
|
-
*/
|
|
273
|
-
#getApp() {
|
|
274
|
-
return this.#parameters.app || new AppFactory2().create(new URL("./app/", import.meta.url));
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* Returns an instance of the encryptor to encrypt
|
|
278
|
-
* signed URLs
|
|
279
|
-
*/
|
|
280
|
-
#createEncryption() {
|
|
281
|
-
return this.#parameters.encryption || new EncryptionFactory4().create();
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* Merge factory params
|
|
285
|
-
* @param params - Partial factory parameters to merge
|
|
286
|
-
*/
|
|
287
|
-
merge(params) {
|
|
288
|
-
Object.assign(this.#parameters, params);
|
|
289
|
-
return this;
|
|
290
|
-
}
|
|
291
|
-
/**
|
|
292
|
-
* Create server instance
|
|
293
|
-
*/
|
|
294
|
-
create() {
|
|
295
|
-
return new Server(
|
|
296
|
-
this.#getApp(),
|
|
297
|
-
this.#createEncryption(),
|
|
298
|
-
this.#getEmitter(),
|
|
299
|
-
this.#getLogger(),
|
|
300
|
-
this.#getConfig()
|
|
301
|
-
);
|
|
302
|
-
}
|
|
131
|
+
#parameters = {};
|
|
132
|
+
#getEmitter() {
|
|
133
|
+
return this.#parameters.emitter || new Emitter(this.#getApp());
|
|
134
|
+
}
|
|
135
|
+
#getLogger() {
|
|
136
|
+
return this.#parameters.logger || new Logger({ enabled: false });
|
|
137
|
+
}
|
|
138
|
+
#getConfig() {
|
|
139
|
+
return defineConfig(this.#parameters.config || {});
|
|
140
|
+
}
|
|
141
|
+
#getApp() {
|
|
142
|
+
return this.#parameters.app || new AppFactory().create(new URL("./app/", import.meta.url));
|
|
143
|
+
}
|
|
144
|
+
#createEncryption() {
|
|
145
|
+
return this.#parameters.encryption || new EncryptionFactory().create();
|
|
146
|
+
}
|
|
147
|
+
merge(params) {
|
|
148
|
+
Object.assign(this.#parameters, params);
|
|
149
|
+
return this;
|
|
150
|
+
}
|
|
151
|
+
create() {
|
|
152
|
+
return new Server(this.#getApp(), this.#createEncryption(), this.#getEmitter(), this.#getLogger(), this.#getConfig());
|
|
153
|
+
}
|
|
303
154
|
};
|
|
304
|
-
|
|
305
|
-
// factories/http_context.ts
|
|
306
|
-
import { Container } from "@adonisjs/fold";
|
|
307
|
-
import { LoggerFactory } from "@adonisjs/logger/factories";
|
|
308
155
|
var HttpContextFactory = class {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
* Returns an instance of the logger class
|
|
327
|
-
*/
|
|
328
|
-
#createLogger() {
|
|
329
|
-
return this.#parameters.logger || new LoggerFactory().create();
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* Merge factory params
|
|
333
|
-
* @param params - Partial factory parameters to merge
|
|
334
|
-
*/
|
|
335
|
-
merge(params) {
|
|
336
|
-
Object.assign(this.#parameters, params);
|
|
337
|
-
return this;
|
|
338
|
-
}
|
|
339
|
-
/**
|
|
340
|
-
* Create HTTP context instance
|
|
341
|
-
*/
|
|
342
|
-
create() {
|
|
343
|
-
return new HttpContext(
|
|
344
|
-
this.#createRequest(),
|
|
345
|
-
this.#createResponse(),
|
|
346
|
-
this.#createLogger(),
|
|
347
|
-
new Container().createResolver()
|
|
348
|
-
);
|
|
349
|
-
}
|
|
350
|
-
};
|
|
351
|
-
export {
|
|
352
|
-
HttpContextFactory,
|
|
353
|
-
QsParserFactory,
|
|
354
|
-
RequestFactory,
|
|
355
|
-
ResponseFactory,
|
|
356
|
-
RouterFactory,
|
|
357
|
-
ServerFactory
|
|
156
|
+
#parameters = {};
|
|
157
|
+
#createRequest() {
|
|
158
|
+
return this.#parameters.request || new HttpRequestFactory().create();
|
|
159
|
+
}
|
|
160
|
+
#createResponse() {
|
|
161
|
+
return this.#parameters.response || new HttpResponseFactory().create();
|
|
162
|
+
}
|
|
163
|
+
#createLogger() {
|
|
164
|
+
return this.#parameters.logger || new LoggerFactory().create();
|
|
165
|
+
}
|
|
166
|
+
merge(params) {
|
|
167
|
+
Object.assign(this.#parameters, params);
|
|
168
|
+
return this;
|
|
169
|
+
}
|
|
170
|
+
create() {
|
|
171
|
+
return new HttpContext(this.#createRequest(), this.#createResponse(), this.#createLogger(), new Container().createResolver());
|
|
172
|
+
}
|
|
358
173
|
};
|
|
174
|
+
export { HttpContextFactory, QsParserFactory, HttpRequestFactory as RequestFactory, HttpResponseFactory as ResponseFactory, RouterFactory, ServerFactory };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Encryption } from '@
|
|
1
|
+
import type { Encryption } from '@boringnode/encryption';
|
|
2
2
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
3
|
-
import {
|
|
3
|
+
import { HttpRequest } from '../src/request.ts';
|
|
4
4
|
import { type RequestConfig } from '../src/types/request.ts';
|
|
5
5
|
type FactoryParameters = {
|
|
6
6
|
url: string;
|
|
@@ -14,7 +14,7 @@ type FactoryParameters = {
|
|
|
14
14
|
* Request factory is used to generate request class instances for
|
|
15
15
|
* testing
|
|
16
16
|
*/
|
|
17
|
-
export declare class
|
|
17
|
+
export declare class HttpRequestFactory {
|
|
18
18
|
#private;
|
|
19
19
|
/**
|
|
20
20
|
* Merge factory params
|
|
@@ -24,6 +24,6 @@ export declare class RequestFactory {
|
|
|
24
24
|
/**
|
|
25
25
|
* Create request
|
|
26
26
|
*/
|
|
27
|
-
create():
|
|
27
|
+
create(): HttpRequest;
|
|
28
28
|
}
|
|
29
29
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Encryption } from '@
|
|
1
|
+
import type { Encryption } from '@boringnode/encryption';
|
|
2
2
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
3
|
-
import {
|
|
3
|
+
import { HttpResponse } from '../src/response.ts';
|
|
4
4
|
import { type Router } from '../src/router/main.ts';
|
|
5
5
|
import { type ResponseConfig } from '../src/types/response.ts';
|
|
6
6
|
type FactoryParameters = {
|
|
@@ -14,7 +14,7 @@ type FactoryParameters = {
|
|
|
14
14
|
* Response factory is used to generate response class instances for
|
|
15
15
|
* testing
|
|
16
16
|
*/
|
|
17
|
-
export declare class
|
|
17
|
+
export declare class HttpResponseFactory {
|
|
18
18
|
#private;
|
|
19
19
|
/**
|
|
20
20
|
* Merge factory params
|
|
@@ -24,6 +24,6 @@ export declare class ResponseFactory {
|
|
|
24
24
|
/**
|
|
25
25
|
* Create response class instance
|
|
26
26
|
*/
|
|
27
|
-
create():
|
|
27
|
+
create(): HttpResponse;
|
|
28
28
|
}
|
|
29
29
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Logger } from '@adonisjs/logger';
|
|
2
2
|
import { Emitter } from '@adonisjs/events';
|
|
3
|
-
import type { Encryption } from '@
|
|
3
|
+
import type { Encryption } from '@boringnode/encryption';
|
|
4
4
|
import type { Application } from '@adonisjs/application';
|
|
5
5
|
import { Server } from '../src/server/main.ts';
|
|
6
6
|
import type { ServerConfig } from '../src/types/server.ts';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
function findRoute(domainsRoutes, routeIdentifier, domain, method, disableLegacyLookup) {
|
|
2
|
+
if (!domain) {
|
|
3
|
+
let route = null;
|
|
4
|
+
for (const routeDomain of Object.keys(domainsRoutes)) {
|
|
5
|
+
route = findRoute(domainsRoutes, routeIdentifier, routeDomain, method, disableLegacyLookup);
|
|
6
|
+
if (route) break;
|
|
7
|
+
}
|
|
8
|
+
return route;
|
|
9
|
+
}
|
|
10
|
+
const routes = domainsRoutes[domain];
|
|
11
|
+
if (!routes) return null;
|
|
12
|
+
const lookupByPattern = !disableLegacyLookup;
|
|
13
|
+
const lookupByController = !disableLegacyLookup;
|
|
14
|
+
return routes.find((route) => {
|
|
15
|
+
if (method && !route.methods.includes(method)) return false;
|
|
16
|
+
if (route.name === routeIdentifier || lookupByPattern && route.pattern === routeIdentifier) return true;
|
|
17
|
+
if (lookupByController && route.handler && typeof route.handler === "object") return "reference" in route.handler && route.handler.reference === routeIdentifier;
|
|
18
|
+
return false;
|
|
19
|
+
}) || null;
|
|
20
|
+
}
|
|
21
|
+
function createURL(pattern, tokens, searchParamsStringifier, params, options) {
|
|
22
|
+
const uriSegments = [];
|
|
23
|
+
const paramsArray = Array.isArray(params) ? params : null;
|
|
24
|
+
const paramsObject = !Array.isArray(params) ? params ?? {} : {};
|
|
25
|
+
let paramsIndex = 0;
|
|
26
|
+
for (const token of tokens) {
|
|
27
|
+
if (token.type === 0) {
|
|
28
|
+
uriSegments.push(token.val === "/" ? "" : `${token.val}${token.end}`);
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (token.type === 2) {
|
|
32
|
+
const values = paramsArray ? paramsArray.slice(paramsIndex) : paramsObject["*"];
|
|
33
|
+
if (!Array.isArray(values) || !values.length) throw new Error(`Cannot make URL for "${pattern}". Invalid value provided for the wildcard param`);
|
|
34
|
+
uriSegments.push(`${values.join("/")}${token.end}`);
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
const paramName = token.val;
|
|
38
|
+
const value = paramsArray ? paramsArray[paramsIndex] : paramsObject[paramName];
|
|
39
|
+
const isDefined = value !== void 0 && value !== null;
|
|
40
|
+
if (token.type === 1 && !isDefined) throw new Error(`Cannot make URL for "${pattern}". Missing value for the "${paramName}" param`);
|
|
41
|
+
if (isDefined) uriSegments.push(`${value}${token.end}`);
|
|
42
|
+
paramsIndex++;
|
|
43
|
+
}
|
|
44
|
+
let URI = `/${uriSegments.join("/")}`;
|
|
45
|
+
if (options?.prefixUrl) URI = `${options?.prefixUrl.replace(/\/$/, "")}${URI}`;
|
|
46
|
+
if (options?.qs) {
|
|
47
|
+
const queryString = searchParamsStringifier(options?.qs);
|
|
48
|
+
URI = queryString ? `${URI}?${queryString}` : URI;
|
|
49
|
+
}
|
|
50
|
+
return URI;
|
|
51
|
+
}
|
|
52
|
+
export { findRoute as n, createURL as t };
|