@h3ravel/core 0.2.0 → 0.4.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.
- package/CHANGELOG.md +27 -1
- package/dist/index.cjs +332 -1346
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -185
- package/dist/index.d.ts +32 -185
- package/dist/index.js +355 -10
- package/dist/index.js.map +1 -1
- package/package.json +3 -4
- package/src/Application.ts +19 -18
- package/src/Container.ts +1 -1
- package/src/Contracts/BindingsContract.ts +6 -6
- package/src/Controller.ts +1 -1
- package/src/Http/Kernel.ts +7 -8
- package/src/Providers/ViewServiceProvider.ts +1 -1
- package/src/ServiceProvider.ts +2 -1
- package/src/Utils/PathLoader.ts +4 -5
- package/tsconfig.json +1 -1
- package/dist/chunk-22XJG4AW.js +0 -743
- package/dist/chunk-22XJG4AW.js.map +0 -1
- package/dist/src-MGSAHSEB.js +0 -19
- package/dist/src-MGSAHSEB.js.map +0 -1
- package/dist/src-UIEMS3XE.js +0 -90
- package/dist/src-UIEMS3XE.js.map +0 -1
- package/dist/src-ZLODNLLQ.js +0 -223
- package/dist/src-ZLODNLLQ.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -6,9 +6,6 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
-
var __esm = (fn, res) => function __init() {
|
|
10
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
11
|
-
};
|
|
12
9
|
var __export = (target, all) => {
|
|
13
10
|
for (var name in all)
|
|
14
11
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -31,1383 +28,372 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
31
28
|
));
|
|
32
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
33
30
|
|
|
34
|
-
// src/
|
|
35
|
-
var Container;
|
|
36
|
-
var init_Container = __esm({
|
|
37
|
-
"src/Container.ts"() {
|
|
38
|
-
"use strict";
|
|
39
|
-
Container = class {
|
|
40
|
-
static {
|
|
41
|
-
__name(this, "Container");
|
|
42
|
-
}
|
|
43
|
-
bindings = /* @__PURE__ */ new Map();
|
|
44
|
-
singletons = /* @__PURE__ */ new Map();
|
|
45
|
-
bind(key, factory) {
|
|
46
|
-
this.bindings.set(key, factory);
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Bind a singleton service to the container
|
|
50
|
-
*/
|
|
51
|
-
singleton(key, factory) {
|
|
52
|
-
this.bindings.set(key, () => {
|
|
53
|
-
if (!this.singletons.has(key)) {
|
|
54
|
-
this.singletons.set(key, factory());
|
|
55
|
-
}
|
|
56
|
-
return this.singletons.get(key);
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Resolve a service from the container
|
|
61
|
-
*/
|
|
62
|
-
make(key) {
|
|
63
|
-
if (this.bindings.has(key)) {
|
|
64
|
-
return this.bindings.get(key)();
|
|
65
|
-
}
|
|
66
|
-
if (typeof key === "function") {
|
|
67
|
-
return this.build(key);
|
|
68
|
-
}
|
|
69
|
-
throw new Error(`No binding found for key: ${typeof key === "string" ? key : key?.name}`);
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Automatically build a class with constructor dependency injection
|
|
73
|
-
*/
|
|
74
|
-
build(ClassType) {
|
|
75
|
-
const paramTypes = Reflect.getMetadata("design:paramtypes", ClassType) || [];
|
|
76
|
-
const dependencies = paramTypes.map((dep) => this.make(dep));
|
|
77
|
-
return new ClassType(...dependencies);
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Check if a service is registered
|
|
81
|
-
*/
|
|
82
|
-
has(key) {
|
|
83
|
-
return this.bindings.has(key);
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
// src/Utils/PathLoader.ts
|
|
90
|
-
var import_path, PathLoader;
|
|
91
|
-
var init_PathLoader = __esm({
|
|
92
|
-
"src/Utils/PathLoader.ts"() {
|
|
93
|
-
"use strict";
|
|
94
|
-
import_path = __toESM(require("path"), 1);
|
|
95
|
-
PathLoader = class {
|
|
96
|
-
static {
|
|
97
|
-
__name(this, "PathLoader");
|
|
98
|
-
}
|
|
99
|
-
paths = {
|
|
100
|
-
base: "",
|
|
101
|
-
views: "/src/resources/views",
|
|
102
|
-
assets: "/public/assets",
|
|
103
|
-
routes: "/src/routes",
|
|
104
|
-
config: "/src/config",
|
|
105
|
-
public: "/public",
|
|
106
|
-
storage: "/src/storage"
|
|
107
|
-
};
|
|
108
|
-
/**
|
|
109
|
-
* Dynamically retrieves a path property from the class.
|
|
110
|
-
* Any property ending with "Path" is accessible automatically.
|
|
111
|
-
*
|
|
112
|
-
* @param name - The base name of the path property
|
|
113
|
-
* @param base - The base path to include to the path
|
|
114
|
-
* @returns
|
|
115
|
-
*/
|
|
116
|
-
getPath(name, base) {
|
|
117
|
-
if (base && name !== "base") {
|
|
118
|
-
return import_path.default.join(base, this.paths[name]);
|
|
119
|
-
}
|
|
120
|
-
return this.paths[name];
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Programatically set the paths.
|
|
124
|
-
*
|
|
125
|
-
* @param name - The base name of the path property
|
|
126
|
-
* @param path - The new path
|
|
127
|
-
* @param base - The base path to include to the path
|
|
128
|
-
*/
|
|
129
|
-
setPath(name, path4, base) {
|
|
130
|
-
if (base && name !== "base") {
|
|
131
|
-
this.paths[name] = import_path.default.join(base, path4);
|
|
132
|
-
}
|
|
133
|
-
this.paths[name] = path4;
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
// ../http/src/Middleware.ts
|
|
140
|
-
var Middleware;
|
|
141
|
-
var init_Middleware = __esm({
|
|
142
|
-
"../http/src/Middleware.ts"() {
|
|
143
|
-
"use strict";
|
|
144
|
-
Middleware = class {
|
|
145
|
-
static {
|
|
146
|
-
__name(this, "Middleware");
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
// ../support/src/Contracts/ObjContract.ts
|
|
153
|
-
var init_ObjContract = __esm({
|
|
154
|
-
"../support/src/Contracts/ObjContract.ts"() {
|
|
155
|
-
"use strict";
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
// ../support/src/Contracts/StrContract.ts
|
|
160
|
-
var init_StrContract = __esm({
|
|
161
|
-
"../support/src/Contracts/StrContract.ts"() {
|
|
162
|
-
"use strict";
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
// ../support/src/Helpers/Arr.ts
|
|
167
|
-
var init_Arr = __esm({
|
|
168
|
-
"../support/src/Helpers/Arr.ts"() {
|
|
169
|
-
"use strict";
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
// ../support/src/Helpers/Number.ts
|
|
174
|
-
var init_Number = __esm({
|
|
175
|
-
"../support/src/Helpers/Number.ts"() {
|
|
176
|
-
"use strict";
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
// ../support/src/Helpers/Obj.ts
|
|
181
|
-
function safeDot(data, key) {
|
|
182
|
-
if (!key) return data;
|
|
183
|
-
return key.split(".").reduce((acc, k) => acc?.[k], data);
|
|
184
|
-
}
|
|
185
|
-
var setNested;
|
|
186
|
-
var init_Obj = __esm({
|
|
187
|
-
"../support/src/Helpers/Obj.ts"() {
|
|
188
|
-
"use strict";
|
|
189
|
-
__name(safeDot, "safeDot");
|
|
190
|
-
setNested = /* @__PURE__ */ __name((obj, key, value) => {
|
|
191
|
-
if (!key.includes(".")) {
|
|
192
|
-
obj[key] = value;
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
const parts = key.split(".");
|
|
196
|
-
let current = obj;
|
|
197
|
-
for (let i = 0; i < parts.length; i++) {
|
|
198
|
-
const part = parts[i];
|
|
199
|
-
if (i === parts.length - 1) {
|
|
200
|
-
current[part] = value;
|
|
201
|
-
} else {
|
|
202
|
-
if (typeof current[part] !== "object" || current[part] === null) {
|
|
203
|
-
current[part] = {};
|
|
204
|
-
}
|
|
205
|
-
current = current[part];
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}, "setNested");
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
// ../support/src/Helpers/Str.ts
|
|
213
|
-
var afterLast, before;
|
|
214
|
-
var init_Str = __esm({
|
|
215
|
-
"../support/src/Helpers/Str.ts"() {
|
|
216
|
-
"use strict";
|
|
217
|
-
init_Obj();
|
|
218
|
-
afterLast = /* @__PURE__ */ __name((value, search) => {
|
|
219
|
-
if (!search) return value;
|
|
220
|
-
const lastIndex = value.lastIndexOf(search);
|
|
221
|
-
return lastIndex !== -1 ? value.slice(lastIndex + search.length) : value;
|
|
222
|
-
}, "afterLast");
|
|
223
|
-
before = /* @__PURE__ */ __name((value, search) => {
|
|
224
|
-
if (!search) return value;
|
|
225
|
-
const index = value.indexOf(search);
|
|
226
|
-
return index !== -1 ? value.slice(0, index) : value;
|
|
227
|
-
}, "before");
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
// ../support/src/index.ts
|
|
232
|
-
var init_src = __esm({
|
|
233
|
-
"../support/src/index.ts"() {
|
|
234
|
-
"use strict";
|
|
235
|
-
init_ObjContract();
|
|
236
|
-
init_StrContract();
|
|
237
|
-
init_Arr();
|
|
238
|
-
init_Number();
|
|
239
|
-
init_Obj();
|
|
240
|
-
init_Str();
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
// ../http/src/Request.ts
|
|
245
|
-
var import_h3, Request;
|
|
246
|
-
var init_Request = __esm({
|
|
247
|
-
"../http/src/Request.ts"() {
|
|
248
|
-
"use strict";
|
|
249
|
-
import_h3 = require("h3");
|
|
250
|
-
init_src();
|
|
251
|
-
Request = class {
|
|
252
|
-
static {
|
|
253
|
-
__name(this, "Request");
|
|
254
|
-
}
|
|
255
|
-
event;
|
|
256
|
-
constructor(event) {
|
|
257
|
-
this.event = event;
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Get all input data (query + body).
|
|
261
|
-
*/
|
|
262
|
-
async all() {
|
|
263
|
-
let data = {
|
|
264
|
-
...(0, import_h3.getRouterParams)(this.event),
|
|
265
|
-
...(0, import_h3.getQuery)(this.event)
|
|
266
|
-
};
|
|
267
|
-
if (this.event.req.method === "POST") {
|
|
268
|
-
data = Object.assign({}, data, Object.fromEntries((await this.event.req.formData()).entries()));
|
|
269
|
-
} else if (this.event.req.method === "PUT") {
|
|
270
|
-
data = Object.fromEntries(Object.entries(await (0, import_h3.readBody)(this.event)));
|
|
271
|
-
}
|
|
272
|
-
return data;
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* Get a single input field from query or body.
|
|
276
|
-
*/
|
|
277
|
-
async input(key, defaultValue) {
|
|
278
|
-
const data = await this.all();
|
|
279
|
-
return data[key] ?? defaultValue;
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* Get route parameters.
|
|
283
|
-
*/
|
|
284
|
-
params() {
|
|
285
|
-
return (0, import_h3.getRouterParams)(this.event);
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* Get query parameters.
|
|
289
|
-
*/
|
|
290
|
-
query() {
|
|
291
|
-
return (0, import_h3.getQuery)(this.event);
|
|
292
|
-
}
|
|
293
|
-
getEvent(key) {
|
|
294
|
-
return safeDot(this.event, key);
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
|
-
});
|
|
299
|
-
|
|
300
|
-
// ../http/src/Response.ts
|
|
301
|
-
var import_h32, Response;
|
|
302
|
-
var init_Response = __esm({
|
|
303
|
-
"../http/src/Response.ts"() {
|
|
304
|
-
"use strict";
|
|
305
|
-
init_src();
|
|
306
|
-
import_h32 = require("h3");
|
|
307
|
-
Response = class {
|
|
308
|
-
static {
|
|
309
|
-
__name(this, "Response");
|
|
310
|
-
}
|
|
311
|
-
event;
|
|
312
|
-
statusCode = 200;
|
|
313
|
-
headers = {};
|
|
314
|
-
constructor(event) {
|
|
315
|
-
this.event = event;
|
|
316
|
-
}
|
|
317
|
-
/**
|
|
318
|
-
* Set HTTP status code.
|
|
319
|
-
*/
|
|
320
|
-
setStatusCode(code) {
|
|
321
|
-
this.statusCode = code;
|
|
322
|
-
this.event.res.status = code;
|
|
323
|
-
return this;
|
|
324
|
-
}
|
|
325
|
-
/**
|
|
326
|
-
* Set a header.
|
|
327
|
-
*/
|
|
328
|
-
setHeader(name, value) {
|
|
329
|
-
this.headers[name] = value;
|
|
330
|
-
return this;
|
|
331
|
-
}
|
|
332
|
-
html(content) {
|
|
333
|
-
this.applyHeaders();
|
|
334
|
-
return (0, import_h32.html)(this.event, content);
|
|
335
|
-
}
|
|
336
|
-
/**
|
|
337
|
-
* Send a JSON response.
|
|
338
|
-
*/
|
|
339
|
-
json(data) {
|
|
340
|
-
this.setHeader("content-type", "application/json; charset=utf-8");
|
|
341
|
-
this.applyHeaders();
|
|
342
|
-
return data;
|
|
343
|
-
}
|
|
344
|
-
/**
|
|
345
|
-
* Send plain text.
|
|
346
|
-
*/
|
|
347
|
-
text(data) {
|
|
348
|
-
this.setHeader("content-type", "text/plain; charset=utf-8");
|
|
349
|
-
this.applyHeaders();
|
|
350
|
-
return data;
|
|
351
|
-
}
|
|
352
|
-
/**
|
|
353
|
-
* Redirect to another URL.
|
|
354
|
-
*/
|
|
355
|
-
redirect(url, status = 302) {
|
|
356
|
-
this.setStatusCode(status);
|
|
357
|
-
return (0, import_h32.redirect)(this.event, url, this.statusCode);
|
|
358
|
-
}
|
|
359
|
-
/**
|
|
360
|
-
* Apply headers before sending response.
|
|
361
|
-
*/
|
|
362
|
-
applyHeaders() {
|
|
363
|
-
Object.entries(this.headers).forEach(([key, value]) => {
|
|
364
|
-
this.event.res.headers.set(key, value);
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
getEvent(key) {
|
|
368
|
-
return safeDot(this.event, key);
|
|
369
|
-
}
|
|
370
|
-
};
|
|
371
|
-
}
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
// ../http/src/Contracts/ControllerContracts.ts
|
|
375
|
-
var init_ControllerContracts = __esm({
|
|
376
|
-
"../http/src/Contracts/ControllerContracts.ts"() {
|
|
377
|
-
"use strict";
|
|
378
|
-
}
|
|
379
|
-
});
|
|
380
|
-
|
|
381
|
-
// ../http/src/Contracts/HttpContract.ts
|
|
382
|
-
var init_HttpContract = __esm({
|
|
383
|
-
"../http/src/Contracts/HttpContract.ts"() {
|
|
384
|
-
"use strict";
|
|
385
|
-
}
|
|
386
|
-
});
|
|
387
|
-
|
|
388
|
-
// ../http/src/Middleware/LogRequests.ts
|
|
389
|
-
var LogRequests;
|
|
390
|
-
var init_LogRequests = __esm({
|
|
391
|
-
"../http/src/Middleware/LogRequests.ts"() {
|
|
392
|
-
"use strict";
|
|
393
|
-
init_src2();
|
|
394
|
-
LogRequests = class extends Middleware {
|
|
395
|
-
static {
|
|
396
|
-
__name(this, "LogRequests");
|
|
397
|
-
}
|
|
398
|
-
async handle({ request }, next) {
|
|
399
|
-
const url = request.getEvent("url");
|
|
400
|
-
console.log(`[${request.getEvent("method")}] ${url.pathname + url.search}`);
|
|
401
|
-
return next();
|
|
402
|
-
}
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
});
|
|
406
|
-
|
|
407
|
-
// ../http/src/Providers/HttpServiceProvider.ts
|
|
408
|
-
var import_h33, HttpServiceProvider;
|
|
409
|
-
var init_HttpServiceProvider = __esm({
|
|
410
|
-
"../http/src/Providers/HttpServiceProvider.ts"() {
|
|
411
|
-
"use strict";
|
|
412
|
-
import_h33 = require("h3");
|
|
413
|
-
init_index();
|
|
414
|
-
HttpServiceProvider = class extends ServiceProvider {
|
|
415
|
-
static {
|
|
416
|
-
__name(this, "HttpServiceProvider");
|
|
417
|
-
}
|
|
418
|
-
register() {
|
|
419
|
-
this.app.singleton("http.app", () => {
|
|
420
|
-
return new import_h33.H3();
|
|
421
|
-
});
|
|
422
|
-
this.app.singleton("http.serve", () => import_h33.serve);
|
|
423
|
-
}
|
|
424
|
-
};
|
|
425
|
-
}
|
|
426
|
-
});
|
|
427
|
-
|
|
428
|
-
// ../http/src/Resources/JsonResource.ts
|
|
429
|
-
var JsonResource;
|
|
430
|
-
var init_JsonResource = __esm({
|
|
431
|
-
"../http/src/Resources/JsonResource.ts"() {
|
|
432
|
-
"use strict";
|
|
433
|
-
JsonResource = class {
|
|
434
|
-
static {
|
|
435
|
-
__name(this, "JsonResource");
|
|
436
|
-
}
|
|
437
|
-
event;
|
|
438
|
-
/**
|
|
439
|
-
* The request instance
|
|
440
|
-
*/
|
|
441
|
-
request;
|
|
442
|
-
/**
|
|
443
|
-
* The response instance
|
|
444
|
-
*/
|
|
445
|
-
response;
|
|
446
|
-
/**
|
|
447
|
-
* The data to send to the client
|
|
448
|
-
*/
|
|
449
|
-
resource;
|
|
450
|
-
/**
|
|
451
|
-
* The final response data object
|
|
452
|
-
*/
|
|
453
|
-
body = {
|
|
454
|
-
data: {}
|
|
455
|
-
};
|
|
456
|
-
/**
|
|
457
|
-
* Flag to track if response should be sent automatically
|
|
458
|
-
*/
|
|
459
|
-
shouldSend = false;
|
|
460
|
-
/**
|
|
461
|
-
* Flag to track if response has been sent
|
|
462
|
-
*/
|
|
463
|
-
responseSent = false;
|
|
464
|
-
/**
|
|
465
|
-
* @param req The request instance
|
|
466
|
-
* @param res The response instance
|
|
467
|
-
* @param rsc The data to send to the client
|
|
468
|
-
*/
|
|
469
|
-
constructor(event, rsc) {
|
|
470
|
-
this.event = event;
|
|
471
|
-
this.request = event.req;
|
|
472
|
-
this.response = event.res;
|
|
473
|
-
this.resource = rsc;
|
|
474
|
-
for (const key of Object.keys(rsc)) {
|
|
475
|
-
if (!(key in this)) {
|
|
476
|
-
Object.defineProperty(this, key, {
|
|
477
|
-
enumerable: true,
|
|
478
|
-
configurable: true,
|
|
479
|
-
get: /* @__PURE__ */ __name(() => this.resource[key], "get"),
|
|
480
|
-
set: /* @__PURE__ */ __name((value) => {
|
|
481
|
-
this.resource[key] = value;
|
|
482
|
-
}, "set")
|
|
483
|
-
});
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
/**
|
|
488
|
-
* Return the data in the expected format
|
|
489
|
-
*
|
|
490
|
-
* @returns
|
|
491
|
-
*/
|
|
492
|
-
data() {
|
|
493
|
-
return this.resource;
|
|
494
|
-
}
|
|
495
|
-
/**
|
|
496
|
-
* Build the response object
|
|
497
|
-
* @returns this
|
|
498
|
-
*/
|
|
499
|
-
json() {
|
|
500
|
-
this.shouldSend = true;
|
|
501
|
-
this.response.status = 200;
|
|
502
|
-
const resource = this.data();
|
|
503
|
-
let data = Array.isArray(resource) ? [
|
|
504
|
-
...resource
|
|
505
|
-
] : {
|
|
506
|
-
...resource
|
|
507
|
-
};
|
|
508
|
-
if (typeof data.data !== "undefined") {
|
|
509
|
-
data = data.data;
|
|
510
|
-
}
|
|
511
|
-
if (!Array.isArray(resource)) {
|
|
512
|
-
delete data.pagination;
|
|
513
|
-
}
|
|
514
|
-
this.body = {
|
|
515
|
-
data
|
|
516
|
-
};
|
|
517
|
-
if (!Array.isArray(resource) && resource.pagination) {
|
|
518
|
-
const meta = this.body.meta ?? {};
|
|
519
|
-
meta.pagination = resource.pagination;
|
|
520
|
-
this.body.meta = meta;
|
|
521
|
-
}
|
|
522
|
-
if (this.resource.pagination && !this.body.meta?.pagination) {
|
|
523
|
-
const meta = this.body.meta ?? {};
|
|
524
|
-
meta.pagination = this.resource.pagination;
|
|
525
|
-
this.body.meta = meta;
|
|
526
|
-
}
|
|
527
|
-
return this;
|
|
528
|
-
}
|
|
529
|
-
/**
|
|
530
|
-
* Add context data to the response object
|
|
531
|
-
* @param data Context data
|
|
532
|
-
* @returns this
|
|
533
|
-
*/
|
|
534
|
-
additional(data) {
|
|
535
|
-
this.shouldSend = true;
|
|
536
|
-
delete data.data;
|
|
537
|
-
delete data.pagination;
|
|
538
|
-
this.body = {
|
|
539
|
-
...this.body,
|
|
540
|
-
...data
|
|
541
|
-
};
|
|
542
|
-
return this;
|
|
543
|
-
}
|
|
544
|
-
/**
|
|
545
|
-
* Send the output to the client
|
|
546
|
-
* @returns this
|
|
547
|
-
*/
|
|
548
|
-
send() {
|
|
549
|
-
this.shouldSend = false;
|
|
550
|
-
if (!this.responseSent) {
|
|
551
|
-
this.#send();
|
|
552
|
-
}
|
|
553
|
-
return this;
|
|
554
|
-
}
|
|
555
|
-
/**
|
|
556
|
-
* Set the status code for this response
|
|
557
|
-
* @param code Status code
|
|
558
|
-
* @returns this
|
|
559
|
-
*/
|
|
560
|
-
status(code) {
|
|
561
|
-
this.response.status = code;
|
|
562
|
-
return this;
|
|
563
|
-
}
|
|
564
|
-
/**
|
|
565
|
-
* Private method to send the response
|
|
566
|
-
*/
|
|
567
|
-
#send() {
|
|
568
|
-
if (!this.responseSent) {
|
|
569
|
-
this.event.context.this.response.json(this.body);
|
|
570
|
-
this.responseSent = true;
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
/**
|
|
574
|
-
* Check if send should be triggered automatically
|
|
575
|
-
*/
|
|
576
|
-
checkSend() {
|
|
577
|
-
if (this.shouldSend && !this.responseSent) {
|
|
578
|
-
this.#send();
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
};
|
|
582
|
-
}
|
|
583
|
-
});
|
|
584
|
-
|
|
585
|
-
// ../http/src/Resources/ApiResource.ts
|
|
586
|
-
function ApiResource(instance) {
|
|
587
|
-
return new Proxy(instance, {
|
|
588
|
-
get(target, prop, receiver) {
|
|
589
|
-
const value = Reflect.get(target, prop, receiver);
|
|
590
|
-
if (typeof value === "function") {
|
|
591
|
-
if (prop === "json" || prop === "additional") {
|
|
592
|
-
return (...args) => {
|
|
593
|
-
const result = value.apply(target, args);
|
|
594
|
-
setImmediate(() => target["checkSend"]());
|
|
595
|
-
return result;
|
|
596
|
-
};
|
|
597
|
-
} else if (prop === "send") {
|
|
598
|
-
return (...args) => {
|
|
599
|
-
target["shouldSend"] = false;
|
|
600
|
-
return value.apply(target, args);
|
|
601
|
-
};
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
return value;
|
|
605
|
-
}
|
|
606
|
-
});
|
|
607
|
-
}
|
|
608
|
-
var init_ApiResource = __esm({
|
|
609
|
-
"../http/src/Resources/ApiResource.ts"() {
|
|
610
|
-
"use strict";
|
|
611
|
-
init_JsonResource();
|
|
612
|
-
__name(ApiResource, "ApiResource");
|
|
613
|
-
}
|
|
614
|
-
});
|
|
615
|
-
|
|
616
|
-
// ../http/src/index.ts
|
|
31
|
+
// src/index.ts
|
|
617
32
|
var src_exports = {};
|
|
618
33
|
__export(src_exports, {
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
var init_src2 = __esm({
|
|
628
|
-
"../http/src/index.ts"() {
|
|
629
|
-
"use strict";
|
|
630
|
-
init_Middleware();
|
|
631
|
-
init_Request();
|
|
632
|
-
init_Response();
|
|
633
|
-
init_ControllerContracts();
|
|
634
|
-
init_HttpContract();
|
|
635
|
-
init_LogRequests();
|
|
636
|
-
init_HttpServiceProvider();
|
|
637
|
-
init_ApiResource();
|
|
638
|
-
init_JsonResource();
|
|
639
|
-
}
|
|
640
|
-
});
|
|
641
|
-
|
|
642
|
-
// ../config/src/ConfigRepository.ts
|
|
643
|
-
var import_node_path, import_promises, ConfigRepository;
|
|
644
|
-
var init_ConfigRepository = __esm({
|
|
645
|
-
"../config/src/ConfigRepository.ts"() {
|
|
646
|
-
"use strict";
|
|
647
|
-
init_src();
|
|
648
|
-
import_node_path = __toESM(require("path"), 1);
|
|
649
|
-
import_promises = require("fs/promises");
|
|
650
|
-
ConfigRepository = class {
|
|
651
|
-
static {
|
|
652
|
-
__name(this, "ConfigRepository");
|
|
653
|
-
}
|
|
654
|
-
app;
|
|
655
|
-
loaded = false;
|
|
656
|
-
configs = {};
|
|
657
|
-
constructor(app) {
|
|
658
|
-
this.app = app;
|
|
659
|
-
}
|
|
660
|
-
get(key, def) {
|
|
661
|
-
return safeDot(this.configs, key) ?? def;
|
|
662
|
-
}
|
|
663
|
-
/**
|
|
664
|
-
* Modify the defined configurations
|
|
665
|
-
*/
|
|
666
|
-
set(key, value) {
|
|
667
|
-
setNested(this.configs, key, value);
|
|
668
|
-
}
|
|
669
|
-
async load() {
|
|
670
|
-
if (!this.loaded) {
|
|
671
|
-
const configPath = this.app.getPath("config");
|
|
672
|
-
const files = await (0, import_promises.readdir)(configPath);
|
|
673
|
-
for (let i = 0; i < files.length; i++) {
|
|
674
|
-
const configModule = await import(import_node_path.default.join(configPath, files[i]));
|
|
675
|
-
const name = files[i].replaceAll(/.ts|js/g, "");
|
|
676
|
-
if (typeof configModule.default === "function") {
|
|
677
|
-
this.configs[name] = configModule.default(this.app);
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
this.loaded = true;
|
|
681
|
-
}
|
|
682
|
-
return this;
|
|
683
|
-
}
|
|
684
|
-
};
|
|
685
|
-
}
|
|
686
|
-
});
|
|
687
|
-
|
|
688
|
-
// ../config/src/EnvLoader.ts
|
|
689
|
-
var EnvLoader;
|
|
690
|
-
var init_EnvLoader = __esm({
|
|
691
|
-
"../config/src/EnvLoader.ts"() {
|
|
692
|
-
"use strict";
|
|
693
|
-
init_src();
|
|
694
|
-
EnvLoader = class {
|
|
695
|
-
static {
|
|
696
|
-
__name(this, "EnvLoader");
|
|
697
|
-
}
|
|
698
|
-
_app;
|
|
699
|
-
constructor(_app) {
|
|
700
|
-
this._app = _app;
|
|
701
|
-
}
|
|
702
|
-
get(key, def) {
|
|
703
|
-
return safeDot(process.env, key) ?? def;
|
|
704
|
-
}
|
|
705
|
-
};
|
|
706
|
-
}
|
|
707
|
-
});
|
|
708
|
-
|
|
709
|
-
// ../config/src/Helpers.ts
|
|
710
|
-
var init_Helpers = __esm({
|
|
711
|
-
"../config/src/Helpers.ts"() {
|
|
712
|
-
"use strict";
|
|
713
|
-
}
|
|
34
|
+
AppServiceProvider: () => AppServiceProvider,
|
|
35
|
+
Application: () => Application,
|
|
36
|
+
Container: () => Container,
|
|
37
|
+
Controller: () => Controller,
|
|
38
|
+
Kernel: () => Kernel,
|
|
39
|
+
PathLoader: () => PathLoader,
|
|
40
|
+
ServiceProvider: () => ServiceProvider,
|
|
41
|
+
ViewServiceProvider: () => ViewServiceProvider
|
|
714
42
|
});
|
|
43
|
+
module.exports = __toCommonJS(src_exports);
|
|
715
44
|
|
|
716
|
-
//
|
|
717
|
-
var
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
45
|
+
// src/Container.ts
|
|
46
|
+
var Container = class {
|
|
47
|
+
static {
|
|
48
|
+
__name(this, "Container");
|
|
49
|
+
}
|
|
50
|
+
bindings = /* @__PURE__ */ new Map();
|
|
51
|
+
singletons = /* @__PURE__ */ new Map();
|
|
52
|
+
bind(key, factory) {
|
|
53
|
+
this.bindings.set(key, factory);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Bind a singleton service to the container
|
|
57
|
+
*/
|
|
58
|
+
singleton(key, factory) {
|
|
59
|
+
this.bindings.set(key, () => {
|
|
60
|
+
if (!this.singletons.has(key)) {
|
|
61
|
+
this.singletons.set(key, factory());
|
|
62
|
+
}
|
|
63
|
+
return this.singletons.get(key);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Resolve a service from the container
|
|
68
|
+
*/
|
|
69
|
+
make(key) {
|
|
70
|
+
if (this.bindings.has(key)) {
|
|
71
|
+
return this.bindings.get(key)();
|
|
72
|
+
}
|
|
73
|
+
if (typeof key === "function") {
|
|
74
|
+
return this.build(key);
|
|
75
|
+
}
|
|
76
|
+
throw new Error(`No binding found for key: ${typeof key === "string" ? key : key?.name}`);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Automatically build a class with constructor dependency injection
|
|
80
|
+
*/
|
|
81
|
+
build(ClassType) {
|
|
82
|
+
const paramTypes = Reflect.getMetadata("design:paramtypes", ClassType) || [];
|
|
83
|
+
const dependencies = paramTypes.map((dep) => this.make(dep));
|
|
84
|
+
return new ClassType(...dependencies);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Check if a service is registered
|
|
88
|
+
*/
|
|
89
|
+
has(key) {
|
|
90
|
+
return this.bindings.has(key);
|
|
746
91
|
}
|
|
747
|
-
}
|
|
92
|
+
};
|
|
748
93
|
|
|
749
|
-
//
|
|
750
|
-
var
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
94
|
+
// src/Utils/PathLoader.ts
|
|
95
|
+
var import_path = __toESM(require("path"), 1);
|
|
96
|
+
var PathLoader = class {
|
|
97
|
+
static {
|
|
98
|
+
__name(this, "PathLoader");
|
|
99
|
+
}
|
|
100
|
+
paths = {
|
|
101
|
+
base: "",
|
|
102
|
+
views: "/src/resources/views",
|
|
103
|
+
assets: "/public/assets",
|
|
104
|
+
routes: "/src/routes",
|
|
105
|
+
config: "/src/config",
|
|
106
|
+
public: "/public",
|
|
107
|
+
storage: "/storage"
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Dynamically retrieves a path property from the class.
|
|
111
|
+
* Any property ending with "Path" is accessible automatically.
|
|
112
|
+
*
|
|
113
|
+
* @param name - The base name of the path property
|
|
114
|
+
* @param base - The base path to include to the path
|
|
115
|
+
* @returns
|
|
116
|
+
*/
|
|
117
|
+
getPath(name, base) {
|
|
118
|
+
if (base && name !== "base") {
|
|
119
|
+
return import_path.default.join(base, this.paths[name]);
|
|
120
|
+
}
|
|
121
|
+
return this.paths[name];
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Programatically set the paths.
|
|
125
|
+
*
|
|
126
|
+
* @param name - The base name of the path property
|
|
127
|
+
* @param path - The new path
|
|
128
|
+
* @param base - The base path to include to the path
|
|
129
|
+
*/
|
|
130
|
+
setPath(name, path2, base) {
|
|
131
|
+
if (base && name !== "base") {
|
|
132
|
+
this.paths[name] = import_path.default.join(base, path2);
|
|
133
|
+
}
|
|
134
|
+
this.paths[name] = path2;
|
|
763
135
|
}
|
|
764
|
-
}
|
|
136
|
+
};
|
|
765
137
|
|
|
766
|
-
//
|
|
767
|
-
var
|
|
768
|
-
|
|
769
|
-
|
|
138
|
+
// src/Application.ts
|
|
139
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
140
|
+
var Application = class _Application extends Container {
|
|
141
|
+
static {
|
|
142
|
+
__name(this, "Application");
|
|
143
|
+
}
|
|
144
|
+
paths = new PathLoader();
|
|
145
|
+
booted = false;
|
|
146
|
+
versions = {
|
|
147
|
+
app: "0",
|
|
148
|
+
ts: "0"
|
|
149
|
+
};
|
|
150
|
+
basePath;
|
|
151
|
+
providers = [];
|
|
152
|
+
externalProviders = [];
|
|
153
|
+
constructor(basePath) {
|
|
154
|
+
super();
|
|
155
|
+
this.basePath = basePath;
|
|
156
|
+
this.setPath("base", basePath);
|
|
157
|
+
this.loadOptions();
|
|
158
|
+
this.registerBaseBindings();
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Register core bindings into the container
|
|
162
|
+
*/
|
|
163
|
+
registerBaseBindings() {
|
|
164
|
+
this.bind(_Application, () => this);
|
|
165
|
+
this.bind("path.base", () => this.basePath);
|
|
166
|
+
this.bind("app.paths", () => this.paths);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Dynamically register all configured providers
|
|
170
|
+
*/
|
|
171
|
+
async registerConfiguredProviders() {
|
|
172
|
+
const providers = await this.getAllProviders();
|
|
173
|
+
for (const ProviderClass of providers) {
|
|
174
|
+
if (!ProviderClass)
|
|
175
|
+
continue;
|
|
176
|
+
const provider = new ProviderClass(this);
|
|
177
|
+
await this.register(provider);
|
|
178
|
+
}
|
|
770
179
|
}
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
180
|
+
async loadOptions() {
|
|
181
|
+
const app = await this.safeImport(this.getPath("base", "package.json"));
|
|
182
|
+
const core = await this.safeImport("../package.json");
|
|
183
|
+
if (app && app.dependencies) {
|
|
184
|
+
this.versions.app = app.dependencies["@h3ravel/core"];
|
|
185
|
+
}
|
|
186
|
+
if (core && core.devDependencies) {
|
|
187
|
+
this.versions.ts = app.devDependencies.typescript;
|
|
188
|
+
}
|
|
777
189
|
}
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
name,
|
|
828
|
-
handler
|
|
829
|
-
});
|
|
830
|
-
this.h3App[method](fullPath, this.resolveHandler(handler, middleware));
|
|
831
|
-
}
|
|
832
|
-
resolveControllerOrHandler(handler, methodName) {
|
|
833
|
-
if (typeof handler === "function" && handler.prototype instanceof Controller) {
|
|
834
|
-
return (ctx) => {
|
|
835
|
-
const controller = new handler(this.app);
|
|
836
|
-
const action = methodName || "index";
|
|
837
|
-
if (typeof controller[action] !== "function") {
|
|
838
|
-
throw new Error(`Method "${action}" not found on controller ${handler.name}`);
|
|
839
|
-
}
|
|
840
|
-
return controller[action](ctx);
|
|
841
|
-
};
|
|
842
|
-
}
|
|
843
|
-
return handler;
|
|
844
|
-
}
|
|
845
|
-
get(path4, handler, methodName, name, middleware = []) {
|
|
846
|
-
this.addRoute("get", path4, this.resolveControllerOrHandler(handler, methodName), name, middleware);
|
|
847
|
-
}
|
|
848
|
-
post(path4, handler, methodName, name, middleware = []) {
|
|
849
|
-
this.addRoute("post", path4, this.resolveControllerOrHandler(handler, methodName), name, middleware);
|
|
850
|
-
}
|
|
851
|
-
put(path4, handler, methodName, name, middleware = []) {
|
|
852
|
-
this.addRoute("put", path4, this.resolveControllerOrHandler(handler, methodName), name, middleware);
|
|
853
|
-
}
|
|
854
|
-
delete(path4, handler, methodName, name, middleware = []) {
|
|
855
|
-
this.addRoute("delete", path4, this.resolveControllerOrHandler(handler, methodName), name, middleware);
|
|
856
|
-
}
|
|
857
|
-
/**
|
|
858
|
-
* API Resource support
|
|
859
|
-
*
|
|
860
|
-
* @param path
|
|
861
|
-
* @param controller
|
|
862
|
-
*/
|
|
863
|
-
apiResource(path4, Controller2, middleware = []) {
|
|
864
|
-
path4 = path4.replace(/\//g, "/");
|
|
865
|
-
const name = afterLast(path4, "/");
|
|
866
|
-
const basePath = `/${path4}`.replace(/\/+/g, "/");
|
|
867
|
-
const controller = new Controller2(this.app);
|
|
868
|
-
this.addRoute("get", basePath, controller.index.bind(controller), `${name}.index`, middleware);
|
|
869
|
-
this.addRoute("post", basePath, controller.store.bind(controller), `${name}.store`, middleware);
|
|
870
|
-
this.addRoute("get", `${basePath}/:id`, controller.show.bind(controller), `${name}.show`, middleware);
|
|
871
|
-
this.addRoute("put", `${basePath}/:id`, controller.update.bind(controller), `${name}.update`, middleware);
|
|
872
|
-
this.addRoute("patch", `${basePath}/:id`, controller.update.bind(controller), `${name}.update`, middleware);
|
|
873
|
-
this.addRoute("delete", `${basePath}/:id`, controller.destroy.bind(controller), `${name}.destroy`, middleware);
|
|
874
|
-
}
|
|
875
|
-
/**
|
|
876
|
-
* Named route URL generator
|
|
877
|
-
*
|
|
878
|
-
* @param name
|
|
879
|
-
* @param params
|
|
880
|
-
* @returns
|
|
881
|
-
*/
|
|
882
|
-
route(name, params = {}) {
|
|
883
|
-
const found = this.routes.find((r) => r.name === name);
|
|
884
|
-
if (!found) return void 0;
|
|
885
|
-
let url = found.path;
|
|
886
|
-
for (const [key, value] of Object.entries(params)) {
|
|
887
|
-
url = url.replace(`:${key}`, value);
|
|
888
|
-
}
|
|
889
|
-
return url;
|
|
890
|
-
}
|
|
891
|
-
/**
|
|
892
|
-
* Grouping
|
|
893
|
-
*
|
|
894
|
-
* @param options
|
|
895
|
-
* @param callback
|
|
896
|
-
*/
|
|
897
|
-
group(options, callback) {
|
|
898
|
-
const prevPrefix = this.groupPrefix;
|
|
899
|
-
const prevMiddleware = [
|
|
900
|
-
...this.groupMiddleware
|
|
901
|
-
];
|
|
902
|
-
this.groupPrefix += options.prefix || "";
|
|
903
|
-
this.groupMiddleware.push(...options.middleware || []);
|
|
904
|
-
callback();
|
|
905
|
-
this.groupPrefix = prevPrefix;
|
|
906
|
-
this.groupMiddleware = prevMiddleware;
|
|
907
|
-
}
|
|
908
|
-
middleware(path4, handler, opts) {
|
|
909
|
-
this.h3App.use(path4, handler, opts);
|
|
190
|
+
/**
|
|
191
|
+
* Load default and optional providers dynamically
|
|
192
|
+
*
|
|
193
|
+
* Auto-Registration Behavior
|
|
194
|
+
*
|
|
195
|
+
* Minimal App: Loads only core, config, http, router by default.
|
|
196
|
+
* Full-Stack App: Installs database, mail, queue, cache → they self-register via their providers.
|
|
197
|
+
*/
|
|
198
|
+
async getConfiguredProviders() {
|
|
199
|
+
return [
|
|
200
|
+
(await this.safeImport("@h3ravel/core")).AppServiceProvider,
|
|
201
|
+
(await this.safeImport("@h3ravel/http")).HttpServiceProvider,
|
|
202
|
+
(await this.safeImport("@h3ravel/config")).ConfigServiceProvider,
|
|
203
|
+
(await this.safeImport("@h3ravel/router")).RouteServiceProvider,
|
|
204
|
+
(await this.safeImport("@h3ravel/router")).AssetsServiceProvider,
|
|
205
|
+
(await this.safeImport("@h3ravel/core")).ViewServiceProvider,
|
|
206
|
+
(await this.safeImport("@h3ravel/database"))?.DatabaseServiceProvider,
|
|
207
|
+
(await this.safeImport("@h3ravel/cache"))?.CacheServiceProvider,
|
|
208
|
+
(await this.safeImport("@h3ravel/console"))?.ConsoleServiceProvider,
|
|
209
|
+
(await this.safeImport("@h3ravel/queue"))?.QueueServiceProvider,
|
|
210
|
+
(await this.safeImport("@h3ravel/mail"))?.MailServiceProvider
|
|
211
|
+
];
|
|
212
|
+
}
|
|
213
|
+
async getAllProviders() {
|
|
214
|
+
const coreProviders = await this.getConfiguredProviders();
|
|
215
|
+
return [
|
|
216
|
+
...coreProviders,
|
|
217
|
+
...this.externalProviders
|
|
218
|
+
];
|
|
219
|
+
}
|
|
220
|
+
registerProviders(providers) {
|
|
221
|
+
this.externalProviders.push(...providers);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Register a provider
|
|
225
|
+
*/
|
|
226
|
+
async register(provider) {
|
|
227
|
+
await provider.register();
|
|
228
|
+
this.providers.push(provider);
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Boot all providers after registration
|
|
232
|
+
*/
|
|
233
|
+
async boot() {
|
|
234
|
+
if (this.booted)
|
|
235
|
+
return;
|
|
236
|
+
for (const provider of this.providers) {
|
|
237
|
+
if (provider.boot) {
|
|
238
|
+
await provider.boot();
|
|
910
239
|
}
|
|
911
|
-
}
|
|
240
|
+
}
|
|
241
|
+
this.booted = true;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Attempt to dynamically import an optional module
|
|
245
|
+
*/
|
|
246
|
+
async safeImport(moduleName) {
|
|
247
|
+
console.log(moduleName);
|
|
248
|
+
try {
|
|
249
|
+
const mod = await import(moduleName);
|
|
250
|
+
return mod.default ?? mod ?? {};
|
|
251
|
+
} catch {
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
912
254
|
}
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
255
|
+
/**
|
|
256
|
+
* Get the base path of the app
|
|
257
|
+
*
|
|
258
|
+
* @returns
|
|
259
|
+
*/
|
|
260
|
+
getBasePath() {
|
|
261
|
+
return this.basePath;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Dynamically retrieves a path property from the class.
|
|
265
|
+
* Any property ending with "Path" is accessible automatically.
|
|
266
|
+
*
|
|
267
|
+
* @param name - The base name of the path property
|
|
268
|
+
* @returns
|
|
269
|
+
*/
|
|
270
|
+
getPath(name, pth) {
|
|
271
|
+
return import_node_path.default.join(this.paths.getPath(name, this.basePath), pth ?? "");
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Programatically set the paths.
|
|
275
|
+
*
|
|
276
|
+
* @param name - The base name of the path property
|
|
277
|
+
* @param path - The new path
|
|
278
|
+
* @returns
|
|
279
|
+
*/
|
|
280
|
+
setPath(name, path2) {
|
|
281
|
+
return this.paths.setPath(name, path2, this.basePath);
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Returns the installed version of the system core and typescript.
|
|
285
|
+
*
|
|
286
|
+
* @returns
|
|
287
|
+
*/
|
|
288
|
+
getVersion(key) {
|
|
289
|
+
return this.versions[key]?.replaceAll(/\^|\~/g, "");
|
|
919
290
|
}
|
|
920
|
-
}
|
|
291
|
+
};
|
|
921
292
|
|
|
922
|
-
//
|
|
923
|
-
var
|
|
924
|
-
|
|
925
|
-
|
|
293
|
+
// src/Controller.ts
|
|
294
|
+
var Controller = class {
|
|
295
|
+
static {
|
|
296
|
+
__name(this, "Controller");
|
|
926
297
|
}
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
var init_Get = __esm({
|
|
931
|
-
"../router/src/Decorators/Get.ts"() {
|
|
932
|
-
"use strict";
|
|
298
|
+
app;
|
|
299
|
+
constructor(app) {
|
|
300
|
+
this.app = app;
|
|
933
301
|
}
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
// ../router/src/Decorators/Middleware.ts
|
|
937
|
-
var init_Middleware2 = __esm({
|
|
938
|
-
"../router/src/Decorators/Middleware.ts"() {
|
|
939
|
-
"use strict";
|
|
302
|
+
show(_ctx) {
|
|
303
|
+
return;
|
|
940
304
|
}
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
// ../router/src/Decorators/Post.ts
|
|
944
|
-
var init_Post = __esm({
|
|
945
|
-
"../router/src/Decorators/Post.ts"() {
|
|
946
|
-
"use strict";
|
|
305
|
+
index(_ctx) {
|
|
306
|
+
return;
|
|
947
307
|
}
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
// ../router/src/Providers/AssetsServiceProvider.ts
|
|
951
|
-
var import_promises2, import_node_path2, import_h34, import_node_fs, AssetsServiceProvider;
|
|
952
|
-
var init_AssetsServiceProvider = __esm({
|
|
953
|
-
"../router/src/Providers/AssetsServiceProvider.ts"() {
|
|
954
|
-
"use strict";
|
|
955
|
-
import_promises2 = require("fs/promises");
|
|
956
|
-
init_index();
|
|
957
|
-
init_src();
|
|
958
|
-
import_node_path2 = require("path");
|
|
959
|
-
import_h34 = require("h3");
|
|
960
|
-
import_node_fs = require("fs");
|
|
961
|
-
AssetsServiceProvider = class extends ServiceProvider {
|
|
962
|
-
static {
|
|
963
|
-
__name(this, "AssetsServiceProvider");
|
|
964
|
-
}
|
|
965
|
-
register() {
|
|
966
|
-
const app = this.app.make("router");
|
|
967
|
-
const config = this.app.make("config");
|
|
968
|
-
const fsconfig = config.get("filesystem");
|
|
969
|
-
const publicPath = this.app.getPath("public");
|
|
970
|
-
app.middleware(`/${fsconfig.public_mask}/**`, (event) => {
|
|
971
|
-
return (0, import_h34.serveStatic)(event, {
|
|
972
|
-
indexNames: [
|
|
973
|
-
"/index.html"
|
|
974
|
-
],
|
|
975
|
-
getContents: /* @__PURE__ */ __name((id) => {
|
|
976
|
-
const newId = id.replace(`/${fsconfig.public_mask}/`, "");
|
|
977
|
-
return (0, import_promises2.readFile)((0, import_node_path2.join)(before(publicPath, newId), newId));
|
|
978
|
-
}, "getContents"),
|
|
979
|
-
getMeta: /* @__PURE__ */ __name(async (id) => {
|
|
980
|
-
const newId = id.replace(`/${fsconfig.public_mask}/`, "");
|
|
981
|
-
const stats = await (0, import_promises2.stat)((0, import_node_path2.join)(before(publicPath, newId), newId)).catch(() => {
|
|
982
|
-
});
|
|
983
|
-
if (stats?.isFile()) {
|
|
984
|
-
return {
|
|
985
|
-
size: stats.size,
|
|
986
|
-
mtime: stats.mtimeMs
|
|
987
|
-
};
|
|
988
|
-
}
|
|
989
|
-
}, "getMeta")
|
|
990
|
-
});
|
|
991
|
-
});
|
|
992
|
-
this.app.singleton("asset", () => {
|
|
993
|
-
return (key, def = "") => {
|
|
994
|
-
try {
|
|
995
|
-
(0, import_node_fs.statSync)((0, import_node_path2.join)(before(publicPath, key), key));
|
|
996
|
-
} catch {
|
|
997
|
-
key = def;
|
|
998
|
-
}
|
|
999
|
-
return (0, import_node_path2.join)(fsconfig.public_mask, key);
|
|
1000
|
-
};
|
|
1001
|
-
});
|
|
1002
|
-
}
|
|
1003
|
-
};
|
|
308
|
+
store(_ctx) {
|
|
309
|
+
return;
|
|
1004
310
|
}
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
// ../router/src/Providers/RouteServiceProvider.ts
|
|
1008
|
-
var import_node_path3, import_promises3, RouteServiceProvider;
|
|
1009
|
-
var init_RouteServiceProvider = __esm({
|
|
1010
|
-
"../router/src/Providers/RouteServiceProvider.ts"() {
|
|
1011
|
-
"use strict";
|
|
1012
|
-
init_Router();
|
|
1013
|
-
init_index();
|
|
1014
|
-
import_node_path3 = __toESM(require("path"), 1);
|
|
1015
|
-
import_promises3 = require("fs/promises");
|
|
1016
|
-
RouteServiceProvider = class extends ServiceProvider {
|
|
1017
|
-
static {
|
|
1018
|
-
__name(this, "RouteServiceProvider");
|
|
1019
|
-
}
|
|
1020
|
-
register() {
|
|
1021
|
-
this.app.singleton("router", () => {
|
|
1022
|
-
const h3App = this.app.make("http.app");
|
|
1023
|
-
return new Router(h3App, this.app);
|
|
1024
|
-
});
|
|
1025
|
-
}
|
|
1026
|
-
/**
|
|
1027
|
-
* Load routes from src/routes
|
|
1028
|
-
*/
|
|
1029
|
-
async boot() {
|
|
1030
|
-
try {
|
|
1031
|
-
const routePath = this.app.getPath("routes");
|
|
1032
|
-
const files = await (0, import_promises3.readdir)(routePath);
|
|
1033
|
-
for (let i = 0; i < files.length; i++) {
|
|
1034
|
-
const routesModule = await import(import_node_path3.default.join(routePath, files[i]));
|
|
1035
|
-
if (typeof routesModule.default === "function") {
|
|
1036
|
-
const router = this.app.make("router");
|
|
1037
|
-
routesModule.default(router);
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1040
|
-
} catch (e) {
|
|
1041
|
-
console.warn("No web routes found or failed to load:", e);
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
1044
|
-
};
|
|
311
|
+
update(_ctx) {
|
|
312
|
+
return;
|
|
1045
313
|
}
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
// ../router/src/index.ts
|
|
1049
|
-
var src_exports3 = {};
|
|
1050
|
-
__export(src_exports3, {
|
|
1051
|
-
AssetsServiceProvider: () => AssetsServiceProvider,
|
|
1052
|
-
RouteServiceProvider: () => RouteServiceProvider,
|
|
1053
|
-
Router: () => Router
|
|
1054
|
-
});
|
|
1055
|
-
var init_src4 = __esm({
|
|
1056
|
-
"../router/src/index.ts"() {
|
|
1057
|
-
"use strict";
|
|
1058
|
-
init_Controller();
|
|
1059
|
-
init_Route();
|
|
1060
|
-
init_Router();
|
|
1061
|
-
init_ApiResource2();
|
|
1062
|
-
init_Controller2();
|
|
1063
|
-
init_Get();
|
|
1064
|
-
init_Middleware2();
|
|
1065
|
-
init_Post();
|
|
1066
|
-
init_AssetsServiceProvider();
|
|
1067
|
-
init_RouteServiceProvider();
|
|
314
|
+
destroy(_ctx) {
|
|
315
|
+
return;
|
|
1068
316
|
}
|
|
1069
|
-
}
|
|
1070
|
-
|
|
1071
|
-
// src/Application.ts
|
|
1072
|
-
var import_node_path4, Application;
|
|
1073
|
-
var init_Application = __esm({
|
|
1074
|
-
"src/Application.ts"() {
|
|
1075
|
-
"use strict";
|
|
1076
|
-
init_Container();
|
|
1077
|
-
init_PathLoader();
|
|
1078
|
-
import_node_path4 = __toESM(require("path"), 1);
|
|
1079
|
-
Application = class _Application extends Container {
|
|
1080
|
-
static {
|
|
1081
|
-
__name(this, "Application");
|
|
1082
|
-
}
|
|
1083
|
-
paths = new PathLoader();
|
|
1084
|
-
booted = false;
|
|
1085
|
-
versions = {
|
|
1086
|
-
app: "0",
|
|
1087
|
-
ts: "0"
|
|
1088
|
-
};
|
|
1089
|
-
basePath;
|
|
1090
|
-
providers = [];
|
|
1091
|
-
externalProviders = [];
|
|
1092
|
-
constructor(basePath) {
|
|
1093
|
-
super();
|
|
1094
|
-
this.basePath = basePath;
|
|
1095
|
-
this.setPath("base", basePath);
|
|
1096
|
-
this.loadOptions();
|
|
1097
|
-
this.registerBaseBindings();
|
|
1098
|
-
}
|
|
1099
|
-
/**
|
|
1100
|
-
* Register core bindings into the container
|
|
1101
|
-
*/
|
|
1102
|
-
registerBaseBindings() {
|
|
1103
|
-
this.bind(_Application, () => this);
|
|
1104
|
-
this.bind("path.base", () => this.basePath);
|
|
1105
|
-
this.bind("app.paths", () => this.paths);
|
|
1106
|
-
}
|
|
1107
|
-
/**
|
|
1108
|
-
* Dynamically register all configured providers
|
|
1109
|
-
*/
|
|
1110
|
-
async registerConfiguredProviders() {
|
|
1111
|
-
const providers = await this.getAllProviders();
|
|
1112
|
-
for (const ProviderClass of providers) {
|
|
1113
|
-
if (!ProviderClass) continue;
|
|
1114
|
-
const provider = new ProviderClass(this);
|
|
1115
|
-
await this.register(provider);
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
|
-
async loadOptions() {
|
|
1119
|
-
const app = await this.safeImport(this.getPath("base", "package.json"));
|
|
1120
|
-
const core = await this.safeImport("../package.json");
|
|
1121
|
-
if (app && app.dependencies) {
|
|
1122
|
-
this.versions.app = app.dependencies["@h3ravel/core"];
|
|
1123
|
-
}
|
|
1124
|
-
if (core && core.devDependencies) {
|
|
1125
|
-
this.versions.ts = app.devDependencies.typescript;
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
|
-
/**
|
|
1129
|
-
* Load default and optional providers dynamically
|
|
1130
|
-
*
|
|
1131
|
-
* Auto-Registration Behavior
|
|
1132
|
-
*
|
|
1133
|
-
* Minimal App: Loads only core, config, http, router by default.
|
|
1134
|
-
* Full-Stack App: Installs database, mail, queue, cache → they self-register via their providers.
|
|
1135
|
-
*/
|
|
1136
|
-
async getConfiguredProviders() {
|
|
1137
|
-
return [
|
|
1138
|
-
(await Promise.resolve().then(() => (init_index(), index_exports))).AppServiceProvider,
|
|
1139
|
-
(await Promise.resolve().then(() => (init_src2(), src_exports))).HttpServiceProvider,
|
|
1140
|
-
(await Promise.resolve().then(() => (init_src3(), src_exports2))).ConfigServiceProvider,
|
|
1141
|
-
(await Promise.resolve().then(() => (init_src4(), src_exports3))).RouteServiceProvider,
|
|
1142
|
-
(await Promise.resolve().then(() => (init_src4(), src_exports3))).AssetsServiceProvider,
|
|
1143
|
-
(await Promise.resolve().then(() => (init_index(), index_exports))).ViewServiceProvider,
|
|
1144
|
-
(await this.safeImport("@h3ravel/database"))?.DatabaseServiceProvider,
|
|
1145
|
-
(await this.safeImport("@h3ravel/cache"))?.CacheServiceProvider,
|
|
1146
|
-
(await this.safeImport("@h3ravel/console"))?.ConsoleServiceProvider,
|
|
1147
|
-
(await this.safeImport("@h3ravel/queue"))?.QueueServiceProvider,
|
|
1148
|
-
(await this.safeImport("@h3ravel/mail"))?.MailServiceProvider
|
|
1149
|
-
];
|
|
1150
|
-
}
|
|
1151
|
-
async getAllProviders() {
|
|
1152
|
-
const coreProviders = await this.getConfiguredProviders();
|
|
1153
|
-
return [
|
|
1154
|
-
...coreProviders,
|
|
1155
|
-
...this.externalProviders
|
|
1156
|
-
];
|
|
1157
|
-
}
|
|
1158
|
-
registerProviders(providers) {
|
|
1159
|
-
this.externalProviders.push(...providers);
|
|
1160
|
-
}
|
|
1161
|
-
/**
|
|
1162
|
-
* Register a provider
|
|
1163
|
-
*/
|
|
1164
|
-
async register(provider) {
|
|
1165
|
-
await provider.register();
|
|
1166
|
-
this.providers.push(provider);
|
|
1167
|
-
}
|
|
1168
|
-
/**
|
|
1169
|
-
* Boot all providers after registration
|
|
1170
|
-
*/
|
|
1171
|
-
async boot() {
|
|
1172
|
-
if (this.booted) return;
|
|
1173
|
-
for (const provider of this.providers) {
|
|
1174
|
-
if (provider.boot) {
|
|
1175
|
-
await provider.boot();
|
|
1176
|
-
}
|
|
1177
|
-
}
|
|
1178
|
-
this.booted = true;
|
|
1179
|
-
}
|
|
1180
|
-
/**
|
|
1181
|
-
* Attempt to dynamically import an optional module
|
|
1182
|
-
*/
|
|
1183
|
-
async safeImport(moduleName) {
|
|
1184
|
-
try {
|
|
1185
|
-
const mod = await import(moduleName);
|
|
1186
|
-
return mod.default ?? mod;
|
|
1187
|
-
} catch {
|
|
1188
|
-
return null;
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
/**
|
|
1192
|
-
* Get the base path of the app
|
|
1193
|
-
*
|
|
1194
|
-
* @returns
|
|
1195
|
-
*/
|
|
1196
|
-
getBasePath() {
|
|
1197
|
-
return this.basePath;
|
|
1198
|
-
}
|
|
1199
|
-
/**
|
|
1200
|
-
* Dynamically retrieves a path property from the class.
|
|
1201
|
-
* Any property ending with "Path" is accessible automatically.
|
|
1202
|
-
*
|
|
1203
|
-
* @param name - The base name of the path property
|
|
1204
|
-
* @returns
|
|
1205
|
-
*/
|
|
1206
|
-
getPath(name, pth) {
|
|
1207
|
-
return import_node_path4.default.join(this.paths.getPath(name, this.basePath), pth ?? "");
|
|
1208
|
-
}
|
|
1209
|
-
/**
|
|
1210
|
-
* Programatically set the paths.
|
|
1211
|
-
*
|
|
1212
|
-
* @param name - The base name of the path property
|
|
1213
|
-
* @param path - The new path
|
|
1214
|
-
* @returns
|
|
1215
|
-
*/
|
|
1216
|
-
setPath(name, path4) {
|
|
1217
|
-
return this.paths.setPath(name, path4, this.basePath);
|
|
1218
|
-
}
|
|
1219
|
-
/**
|
|
1220
|
-
* Returns the installed version of the system core and typescript.
|
|
1221
|
-
*
|
|
1222
|
-
* @returns
|
|
1223
|
-
*/
|
|
1224
|
-
getVersion(key) {
|
|
1225
|
-
return this.versions[key]?.replaceAll(/\^|\~/g, "");
|
|
1226
|
-
}
|
|
1227
|
-
};
|
|
1228
|
-
}
|
|
1229
|
-
});
|
|
1230
|
-
|
|
1231
|
-
// src/Controller.ts
|
|
1232
|
-
var Controller;
|
|
1233
|
-
var init_Controller3 = __esm({
|
|
1234
|
-
"src/Controller.ts"() {
|
|
1235
|
-
"use strict";
|
|
1236
|
-
Controller = class {
|
|
1237
|
-
static {
|
|
1238
|
-
__name(this, "Controller");
|
|
1239
|
-
}
|
|
1240
|
-
app;
|
|
1241
|
-
constructor(app) {
|
|
1242
|
-
this.app = app;
|
|
1243
|
-
}
|
|
1244
|
-
show(_ctx) {
|
|
1245
|
-
return;
|
|
1246
|
-
}
|
|
1247
|
-
index(_ctx) {
|
|
1248
|
-
return;
|
|
1249
|
-
}
|
|
1250
|
-
store(_ctx) {
|
|
1251
|
-
return;
|
|
1252
|
-
}
|
|
1253
|
-
update(_ctx) {
|
|
1254
|
-
return;
|
|
1255
|
-
}
|
|
1256
|
-
destroy(_ctx) {
|
|
1257
|
-
return;
|
|
1258
|
-
}
|
|
1259
|
-
};
|
|
1260
|
-
}
|
|
1261
|
-
});
|
|
317
|
+
};
|
|
1262
318
|
|
|
1263
319
|
// src/ServiceProvider.ts
|
|
1264
|
-
var ServiceProvider
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
"use strict";
|
|
1268
|
-
ServiceProvider = class {
|
|
1269
|
-
static {
|
|
1270
|
-
__name(this, "ServiceProvider");
|
|
1271
|
-
}
|
|
1272
|
-
app;
|
|
1273
|
-
constructor(app) {
|
|
1274
|
-
this.app = app;
|
|
1275
|
-
}
|
|
1276
|
-
};
|
|
1277
|
-
}
|
|
1278
|
-
});
|
|
1279
|
-
|
|
1280
|
-
// src/Contracts/BindingsContract.ts
|
|
1281
|
-
var init_BindingsContract = __esm({
|
|
1282
|
-
"src/Contracts/BindingsContract.ts"() {
|
|
1283
|
-
"use strict";
|
|
320
|
+
var ServiceProvider = class {
|
|
321
|
+
static {
|
|
322
|
+
__name(this, "ServiceProvider");
|
|
1284
323
|
}
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
var init_Handler = __esm({
|
|
1289
|
-
"src/Exceptions/Handler.ts"() {
|
|
1290
|
-
"use strict";
|
|
324
|
+
app;
|
|
325
|
+
constructor(app) {
|
|
326
|
+
this.app = app;
|
|
1291
327
|
}
|
|
1292
|
-
}
|
|
328
|
+
};
|
|
1293
329
|
|
|
1294
330
|
// src/Http/Kernel.ts
|
|
1295
|
-
var Kernel
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
}, "runner");
|
|
1331
|
-
return runner(0);
|
|
1332
|
-
}
|
|
1333
|
-
isPlainObject(value) {
|
|
1334
|
-
return typeof value === "object" && value !== null && (value.constructor === Object || value.constructor === Array);
|
|
1335
|
-
}
|
|
1336
|
-
};
|
|
331
|
+
var Kernel = class {
|
|
332
|
+
static {
|
|
333
|
+
__name(this, "Kernel");
|
|
334
|
+
}
|
|
335
|
+
context;
|
|
336
|
+
middleware;
|
|
337
|
+
constructor(context, middleware = []) {
|
|
338
|
+
this.context = context;
|
|
339
|
+
this.middleware = middleware;
|
|
340
|
+
}
|
|
341
|
+
async handle(event, next) {
|
|
342
|
+
const ctx = this.context(event);
|
|
343
|
+
const result = await this.runMiddleware(ctx, () => next(ctx));
|
|
344
|
+
if (result !== void 0 && this.isPlainObject(result)) {
|
|
345
|
+
event.res.headers.set("Content-Type", "application/json; charset=UTF-8");
|
|
346
|
+
}
|
|
347
|
+
return result;
|
|
348
|
+
}
|
|
349
|
+
async runMiddleware(context, next) {
|
|
350
|
+
let index = -1;
|
|
351
|
+
const runner = /* @__PURE__ */ __name(async (i) => {
|
|
352
|
+
if (i <= index)
|
|
353
|
+
throw new Error("next() called multiple times");
|
|
354
|
+
index = i;
|
|
355
|
+
const middleware = this.middleware[i];
|
|
356
|
+
if (middleware) {
|
|
357
|
+
return middleware.handle(context, () => runner(i + 1));
|
|
358
|
+
} else {
|
|
359
|
+
return next(context);
|
|
360
|
+
}
|
|
361
|
+
}, "runner");
|
|
362
|
+
return runner(0);
|
|
363
|
+
}
|
|
364
|
+
isPlainObject(value) {
|
|
365
|
+
return typeof value === "object" && value !== null && (value.constructor === Object || value.constructor === Array);
|
|
1337
366
|
}
|
|
1338
|
-
}
|
|
367
|
+
};
|
|
1339
368
|
|
|
1340
369
|
// src/Providers/AppServiceProvider.ts
|
|
1341
|
-
var import_reflect_metadata
|
|
1342
|
-
var
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
import_reflect_metadata = require("reflect-metadata");
|
|
1346
|
-
init_ServiceProvider();
|
|
1347
|
-
AppServiceProvider = class extends ServiceProvider {
|
|
1348
|
-
static {
|
|
1349
|
-
__name(this, "AppServiceProvider");
|
|
1350
|
-
}
|
|
1351
|
-
register() {
|
|
1352
|
-
}
|
|
1353
|
-
};
|
|
370
|
+
var import_reflect_metadata = require("reflect-metadata");
|
|
371
|
+
var AppServiceProvider = class extends ServiceProvider {
|
|
372
|
+
static {
|
|
373
|
+
__name(this, "AppServiceProvider");
|
|
1354
374
|
}
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
// src/Providers/ViewServiceProvider.ts
|
|
1358
|
-
var import_edge, ViewServiceProvider;
|
|
1359
|
-
var init_ViewServiceProvider = __esm({
|
|
1360
|
-
"src/Providers/ViewServiceProvider.ts"() {
|
|
1361
|
-
"use strict";
|
|
1362
|
-
import_edge = require("edge.js");
|
|
1363
|
-
init_index();
|
|
1364
|
-
ViewServiceProvider = class extends ServiceProvider {
|
|
1365
|
-
static {
|
|
1366
|
-
__name(this, "ViewServiceProvider");
|
|
1367
|
-
}
|
|
1368
|
-
register() {
|
|
1369
|
-
const config = this.app.make("config");
|
|
1370
|
-
const edge = import_edge.Edge.create({
|
|
1371
|
-
cache: process.env.NODE_ENV === "production"
|
|
1372
|
-
});
|
|
1373
|
-
edge.mount(this.app.getPath("views"));
|
|
1374
|
-
edge.global("asset", this.app.make("asset"));
|
|
1375
|
-
edge.global("config", config.get);
|
|
1376
|
-
edge.global("app", this.app);
|
|
1377
|
-
this.app.bind("view", () => edge);
|
|
1378
|
-
}
|
|
1379
|
-
};
|
|
375
|
+
register() {
|
|
1380
376
|
}
|
|
1381
|
-
}
|
|
377
|
+
};
|
|
1382
378
|
|
|
1383
|
-
// src/
|
|
1384
|
-
var
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
init_Container();
|
|
1400
|
-
init_Controller3();
|
|
1401
|
-
init_ServiceProvider();
|
|
1402
|
-
init_BindingsContract();
|
|
1403
|
-
init_Handler();
|
|
1404
|
-
init_Kernel();
|
|
1405
|
-
init_AppServiceProvider();
|
|
1406
|
-
init_ViewServiceProvider();
|
|
1407
|
-
init_PathLoader();
|
|
379
|
+
// src/Providers/ViewServiceProvider.ts
|
|
380
|
+
var import_edge = require("edge.js");
|
|
381
|
+
var ViewServiceProvider = class extends ServiceProvider {
|
|
382
|
+
static {
|
|
383
|
+
__name(this, "ViewServiceProvider");
|
|
384
|
+
}
|
|
385
|
+
register() {
|
|
386
|
+
const config = this.app.make("config");
|
|
387
|
+
const edge = import_edge.Edge.create({
|
|
388
|
+
cache: process.env.NODE_ENV === "production"
|
|
389
|
+
});
|
|
390
|
+
edge.mount(this.app.getPath("views"));
|
|
391
|
+
edge.global("asset", this.app.make("asset"));
|
|
392
|
+
edge.global("config", config.get);
|
|
393
|
+
edge.global("app", this.app);
|
|
394
|
+
this.app.bind("view", () => edge);
|
|
1408
395
|
}
|
|
1409
|
-
}
|
|
1410
|
-
init_index();
|
|
396
|
+
};
|
|
1411
397
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1412
398
|
0 && (module.exports = {
|
|
1413
399
|
AppServiceProvider,
|