@h3ravel/core 1.19.2 → 1.20.1
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/dist/app.globals.d.ts +3 -1
- package/dist/index.cjs +14 -11
- package/dist/index.d.ts +5 -4
- package/dist/index.js +16 -8
- package/package.json +8 -8
- package/dist/index.d.cts +0 -482
package/dist/app.globals.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { HTTPResponse } from 'h3'
|
|
2
|
+
|
|
1
3
|
export { }
|
|
2
4
|
|
|
3
5
|
declare global {
|
|
@@ -35,7 +37,7 @@ declare global {
|
|
|
35
37
|
* @param viewPath
|
|
36
38
|
* @param params
|
|
37
39
|
*/
|
|
38
|
-
function view (viewPath: string, params?: Record<string, any> | undefined): Promise<
|
|
40
|
+
function view (viewPath: string, params?: Record<string, any> | undefined): Promise<HTTPResponse>
|
|
39
41
|
|
|
40
42
|
/**
|
|
41
43
|
* Get static asset
|
package/dist/index.cjs
CHANGED
|
@@ -23,25 +23,20 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
//#endregion
|
|
24
24
|
require("reflect-metadata");
|
|
25
25
|
let __h3ravel_shared = require("@h3ravel/shared");
|
|
26
|
-
__h3ravel_shared = __toESM(__h3ravel_shared);
|
|
27
26
|
let __h3ravel_support = require("@h3ravel/support");
|
|
28
|
-
__h3ravel_support = __toESM(__h3ravel_support);
|
|
29
27
|
let fast_glob = require("fast-glob");
|
|
30
28
|
fast_glob = __toESM(fast_glob);
|
|
31
29
|
let node_path = require("node:path");
|
|
32
30
|
node_path = __toESM(node_path);
|
|
33
31
|
let detect_port = require("detect-port");
|
|
34
|
-
detect_port = __toESM(detect_port);
|
|
35
32
|
let dotenv = require("dotenv");
|
|
36
33
|
dotenv = __toESM(dotenv);
|
|
37
34
|
let dotenv_expand = require("dotenv-expand");
|
|
38
35
|
dotenv_expand = __toESM(dotenv_expand);
|
|
39
36
|
let node_fs_promises = require("node:fs/promises");
|
|
40
|
-
node_fs_promises = __toESM(node_fs_promises);
|
|
41
37
|
let semver = require("semver");
|
|
42
38
|
semver = __toESM(semver);
|
|
43
39
|
let __h3ravel_http = require("@h3ravel/http");
|
|
44
|
-
__h3ravel_http = __toESM(__h3ravel_http);
|
|
45
40
|
|
|
46
41
|
//#region src/Container.ts
|
|
47
42
|
var Container = class {
|
|
@@ -378,6 +373,7 @@ var Registerer = class Registerer {
|
|
|
378
373
|
//#region src/Application.ts
|
|
379
374
|
var Application = class Application extends Container {
|
|
380
375
|
paths = new __h3ravel_shared.PathLoader();
|
|
376
|
+
context;
|
|
381
377
|
tries = 0;
|
|
382
378
|
booted = false;
|
|
383
379
|
basePath;
|
|
@@ -690,11 +686,18 @@ const h3ravel = async (providers = [], basePath = process.cwd(), config = {
|
|
|
690
686
|
await app.quickStartup(providers, config.filteredProviders, config.autoload);
|
|
691
687
|
try {
|
|
692
688
|
h3App = app.make("http.app");
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
689
|
+
app.context = async (event) => {
|
|
690
|
+
if (event._h3ravelContext) return event._h3ravelContext;
|
|
691
|
+
__h3ravel_http.Request.enableHttpMethodParameterOverride();
|
|
692
|
+
const ctx = __h3ravel_http.HttpContext.init({
|
|
693
|
+
app,
|
|
694
|
+
request: await __h3ravel_http.Request.create(event, app),
|
|
695
|
+
response: new __h3ravel_http.Response(event, app)
|
|
696
|
+
});
|
|
697
|
+
event._h3ravelContext = ctx;
|
|
698
|
+
return ctx;
|
|
699
|
+
};
|
|
700
|
+
const kernel = new Kernel(async (event) => app.context(event), [new __h3ravel_http.LogRequests()]);
|
|
698
701
|
h3App.use((event) => kernel.handle(event, middleware));
|
|
699
702
|
} catch {
|
|
700
703
|
if (!h3App && config.h3) h3App = config.h3;
|
|
@@ -734,7 +737,7 @@ var Kernel = class {
|
|
|
734
737
|
/**
|
|
735
738
|
* Convert the raw event into a standardized HttpContext
|
|
736
739
|
*/
|
|
737
|
-
const ctx = this.context(event);
|
|
740
|
+
const ctx = await this.context(event);
|
|
738
741
|
const { app } = ctx.request;
|
|
739
742
|
/**
|
|
740
743
|
* Bind HTTP Response instance to the service container
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference path="./app.globals.d.ts" />
|
|
2
|
-
import "reflect-metadata";
|
|
3
2
|
import { Bindings, HttpContext, IApplication, IContainer, IController, IMiddleware, IPathName, IServiceProvider, PathLoader, UseKey } from "@h3ravel/shared";
|
|
4
3
|
import { H3, H3Event } from "h3";
|
|
4
|
+
import { HttpContext as HttpContext$1 } from "@h3ravel/http";
|
|
5
5
|
|
|
6
6
|
//#region src/Contracts/ServiceProviderConstructor.d.ts
|
|
7
7
|
type ServiceProviderConstructor = (new (app: Application) => ServiceProvider) & IServiceProvider;
|
|
@@ -109,6 +109,7 @@ declare abstract class ServiceProvider extends Inference {
|
|
|
109
109
|
//#region src/Application.d.ts
|
|
110
110
|
declare class Application extends Container implements IApplication {
|
|
111
111
|
paths: PathLoader;
|
|
112
|
+
context?: (event: H3Event) => Promise<HttpContext>;
|
|
112
113
|
private tries;
|
|
113
114
|
private booted;
|
|
114
115
|
private basePath;
|
|
@@ -317,7 +318,7 @@ config?: EntryConfig,
|
|
|
317
318
|
/**
|
|
318
319
|
* final middleware function to call once the server is fired up
|
|
319
320
|
*/
|
|
320
|
-
middleware?: (ctx: HttpContext) => Promise<unknown>) => Promise<Application>;
|
|
321
|
+
middleware?: (ctx: HttpContext$1) => Promise<unknown>) => Promise<Application>;
|
|
321
322
|
//#endregion
|
|
322
323
|
//#region src/Http/Kernel.d.ts
|
|
323
324
|
/**
|
|
@@ -325,13 +326,13 @@ middleware?: (ctx: HttpContext) => Promise<unknown>) => Promise<Application>;
|
|
|
325
326
|
* It acts as the core middleware pipeline for HTTP requests.
|
|
326
327
|
*/
|
|
327
328
|
declare class Kernel {
|
|
328
|
-
protected context: (event: H3Event) => HttpContext
|
|
329
|
+
protected context: (event: H3Event) => HttpContext | Promise<HttpContext>;
|
|
329
330
|
protected middleware: IMiddleware[];
|
|
330
331
|
/**
|
|
331
332
|
* @param context - A factory function that converts an H3Event into an HttpContext.
|
|
332
333
|
* @param middleware - An array of middleware classes that will be executed in sequence.
|
|
333
334
|
*/
|
|
334
|
-
constructor(context: (event: H3Event) => HttpContext
|
|
335
|
+
constructor(context: (event: H3Event) => HttpContext | Promise<HttpContext>, middleware?: IMiddleware[]);
|
|
335
336
|
/**
|
|
336
337
|
* Handles an incoming request and passes it through middleware before invoking the next handler.
|
|
337
338
|
*
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
|
-
import { FileSystem,
|
|
2
|
+
import { FileSystem, Logger, PathLoader } from "@h3ravel/shared";
|
|
3
3
|
import { InvalidArgumentException, Str, dd, dump, str } from "@h3ravel/support";
|
|
4
4
|
import fg from "fast-glob";
|
|
5
5
|
import path from "node:path";
|
|
@@ -8,7 +8,7 @@ import dotenv from "dotenv";
|
|
|
8
8
|
import dotenvExpand from "dotenv-expand";
|
|
9
9
|
import { readFile } from "node:fs/promises";
|
|
10
10
|
import semver from "semver";
|
|
11
|
-
import { LogRequests, Request, Response } from "@h3ravel/http";
|
|
11
|
+
import { HttpContext as HttpContext$1, LogRequests, Request, Response } from "@h3ravel/http";
|
|
12
12
|
|
|
13
13
|
//#region src/Container.ts
|
|
14
14
|
var Container = class {
|
|
@@ -345,6 +345,7 @@ var Registerer = class Registerer {
|
|
|
345
345
|
//#region src/Application.ts
|
|
346
346
|
var Application = class Application extends Container {
|
|
347
347
|
paths = new PathLoader();
|
|
348
|
+
context;
|
|
348
349
|
tries = 0;
|
|
349
350
|
booted = false;
|
|
350
351
|
basePath;
|
|
@@ -657,11 +658,18 @@ const h3ravel = async (providers = [], basePath = process.cwd(), config = {
|
|
|
657
658
|
await app.quickStartup(providers, config.filteredProviders, config.autoload);
|
|
658
659
|
try {
|
|
659
660
|
h3App = app.make("http.app");
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
661
|
+
app.context = async (event) => {
|
|
662
|
+
if (event._h3ravelContext) return event._h3ravelContext;
|
|
663
|
+
Request.enableHttpMethodParameterOverride();
|
|
664
|
+
const ctx = HttpContext$1.init({
|
|
665
|
+
app,
|
|
666
|
+
request: await Request.create(event, app),
|
|
667
|
+
response: new Response(event, app)
|
|
668
|
+
});
|
|
669
|
+
event._h3ravelContext = ctx;
|
|
670
|
+
return ctx;
|
|
671
|
+
};
|
|
672
|
+
const kernel = new Kernel(async (event) => app.context(event), [new LogRequests()]);
|
|
665
673
|
h3App.use((event) => kernel.handle(event, middleware));
|
|
666
674
|
} catch {
|
|
667
675
|
if (!h3App && config.h3) h3App = config.h3;
|
|
@@ -701,7 +709,7 @@ var Kernel = class {
|
|
|
701
709
|
/**
|
|
702
710
|
* Convert the raw event into a standardized HttpContext
|
|
703
711
|
*/
|
|
704
|
-
const ctx = this.context(event);
|
|
712
|
+
const ctx = await this.context(event);
|
|
705
713
|
const { app } = ctx.request;
|
|
706
714
|
/**
|
|
707
715
|
* Bind HTTP Response instance to the service container
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h3ravel/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.1",
|
|
4
4
|
"description": "Core application container, lifecycle management and service providers for H3ravel.",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./dist/index.
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"module": "./dist/index.js",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
-
"types": "./dist/index.d.ts",
|
|
12
11
|
"import": "./dist/index.js",
|
|
13
12
|
"require": "./dist/index.cjs"
|
|
14
|
-
}
|
|
13
|
+
},
|
|
14
|
+
"./*": "./*"
|
|
15
15
|
},
|
|
16
16
|
"typesVersions": {
|
|
17
17
|
"*": {
|
|
@@ -46,16 +46,16 @@
|
|
|
46
46
|
"chalk": "^5.6.2",
|
|
47
47
|
"commander": "^14.0.1",
|
|
48
48
|
"detect-port": "^2.1.0",
|
|
49
|
-
"dotenv": "^17.2.
|
|
49
|
+
"dotenv": "^17.2.3",
|
|
50
50
|
"dotenv-expand": "^12.0.3",
|
|
51
51
|
"fast-glob": "^3.3.3",
|
|
52
|
-
"h3": "2.0.
|
|
52
|
+
"h3": "2.0.1-rc.5",
|
|
53
53
|
"reflect-metadata": "^0.2.2",
|
|
54
54
|
"semver": "^7.7.2",
|
|
55
55
|
"srvx": "^0.8.7",
|
|
56
56
|
"tslib": "^2.8.1",
|
|
57
|
-
"@h3ravel/shared": "^0.
|
|
58
|
-
"@h3ravel/support": "^0.14.
|
|
57
|
+
"@h3ravel/shared": "^0.26.1",
|
|
58
|
+
"@h3ravel/support": "^0.14.5"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/semver": "^7.7.1",
|
package/dist/index.d.cts
DELETED
|
@@ -1,482 +0,0 @@
|
|
|
1
|
-
/// <reference path="./app.globals.d.ts" />
|
|
2
|
-
import { Bindings, HttpContext, IApplication, IContainer, IController, IMiddleware, IPathName, IServiceProvider, PathLoader, UseKey } from "@h3ravel/shared";
|
|
3
|
-
import { H3, H3Event } from "h3";
|
|
4
|
-
|
|
5
|
-
//#region src/Contracts/ServiceProviderConstructor.d.ts
|
|
6
|
-
type ServiceProviderConstructor = (new (app: Application) => ServiceProvider) & IServiceProvider;
|
|
7
|
-
type AServiceProvider = (new (_app: Application) => ServiceProvider) & Partial<ServiceProvider>;
|
|
8
|
-
type OServiceProvider = (new (_app: Application) => Partial<ServiceProvider>) & Partial<ServiceProvider>;
|
|
9
|
-
//#endregion
|
|
10
|
-
//#region src/Container.d.ts
|
|
11
|
-
type IBinding = UseKey | (new (..._args: any[]) => unknown);
|
|
12
|
-
declare class Container implements IContainer {
|
|
13
|
-
bindings: Map<IBinding, () => unknown>;
|
|
14
|
-
singletons: Map<IBinding, unknown>;
|
|
15
|
-
/**
|
|
16
|
-
* Check if the target has any decorators
|
|
17
|
-
*
|
|
18
|
-
* @param target
|
|
19
|
-
* @returns
|
|
20
|
-
*/
|
|
21
|
-
static hasAnyDecorator<C extends abstract new (...args: any[]) => any>(target: C): boolean;
|
|
22
|
-
static hasAnyDecorator<F extends (...args: any[]) => any>(target: F): boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Bind a transient service to the container
|
|
25
|
-
*/
|
|
26
|
-
bind<T>(key: new (...args: any[]) => T, factory: () => T): void;
|
|
27
|
-
bind<T extends UseKey>(key: T, factory: () => Bindings[T]): void;
|
|
28
|
-
/**
|
|
29
|
-
* Remove one or more transient services from the container
|
|
30
|
-
*/
|
|
31
|
-
unbind<T extends UseKey>(key: T | T[]): void;
|
|
32
|
-
/**
|
|
33
|
-
* Bind a singleton service to the container
|
|
34
|
-
*/
|
|
35
|
-
singleton<T extends UseKey>(key: T | (new (..._args: any[]) => Bindings[T]), factory: (app: this) => Bindings[T]): void;
|
|
36
|
-
/**
|
|
37
|
-
* Resolve a service from the container
|
|
38
|
-
*/
|
|
39
|
-
make<T extends UseKey>(key: T): Bindings[T];
|
|
40
|
-
make<C extends abstract new (...args: any[]) => any>(key: C): InstanceType<C>;
|
|
41
|
-
make<F extends (...args: any[]) => any>(key: F): ReturnType<F>;
|
|
42
|
-
/**
|
|
43
|
-
* Automatically build a class with constructor dependency injection
|
|
44
|
-
*/
|
|
45
|
-
private build;
|
|
46
|
-
/**
|
|
47
|
-
* Check if a service is registered
|
|
48
|
-
*/
|
|
49
|
-
has(key: UseKey): boolean;
|
|
50
|
-
}
|
|
51
|
-
//#endregion
|
|
52
|
-
//#region src/ServiceProvider.d.ts
|
|
53
|
-
declare const Inference: {
|
|
54
|
-
new (): IServiceProvider;
|
|
55
|
-
};
|
|
56
|
-
declare abstract class ServiceProvider extends Inference {
|
|
57
|
-
/**
|
|
58
|
-
* The current app instance
|
|
59
|
-
*/
|
|
60
|
-
protected app: Application;
|
|
61
|
-
/**
|
|
62
|
-
* Unique Identifier for the service providers
|
|
63
|
-
*/
|
|
64
|
-
static uid?: number;
|
|
65
|
-
/**
|
|
66
|
-
* Sort order
|
|
67
|
-
*/
|
|
68
|
-
static order?: `before:${string}` | `after:${string}` | string | undefined;
|
|
69
|
-
/**
|
|
70
|
-
* Sort priority
|
|
71
|
-
*/
|
|
72
|
-
static priority: number;
|
|
73
|
-
/**
|
|
74
|
-
* Indicate that this service provider only runs in console
|
|
75
|
-
*/
|
|
76
|
-
static console: boolean;
|
|
77
|
-
/**
|
|
78
|
-
* List of registered console commands
|
|
79
|
-
*/
|
|
80
|
-
registeredCommands?: (new (app: any, kernel: any) => any)[];
|
|
81
|
-
constructor(app: Application);
|
|
82
|
-
/**
|
|
83
|
-
* Register bindings to the container.
|
|
84
|
-
* Runs before boot().
|
|
85
|
-
*/
|
|
86
|
-
abstract register(...app: unknown[]): void | Promise<void>;
|
|
87
|
-
/**
|
|
88
|
-
* Perform post-registration booting of services.
|
|
89
|
-
* Runs after all providers have been registered.
|
|
90
|
-
*/
|
|
91
|
-
boot?(...app: unknown[]): void | Promise<void>;
|
|
92
|
-
/**
|
|
93
|
-
* Register the listed service providers.
|
|
94
|
-
*
|
|
95
|
-
* @param commands An array of console commands to register.
|
|
96
|
-
*
|
|
97
|
-
* @deprecated since version 1.16.0. Will be removed in future versions, use `registerCommands` instead
|
|
98
|
-
*/
|
|
99
|
-
commands(commands: (new (app: any, kernel: any) => any)[]): void;
|
|
100
|
-
/**
|
|
101
|
-
* Register the listed service providers.
|
|
102
|
-
*
|
|
103
|
-
* @param commands An array of console commands to register.
|
|
104
|
-
*/
|
|
105
|
-
registerCommands(commands: (new (app: any, kernel: any) => any)[]): void;
|
|
106
|
-
}
|
|
107
|
-
//#endregion
|
|
108
|
-
//#region src/Application.d.ts
|
|
109
|
-
declare class Application extends Container implements IApplication {
|
|
110
|
-
paths: PathLoader;
|
|
111
|
-
private tries;
|
|
112
|
-
private booted;
|
|
113
|
-
private basePath;
|
|
114
|
-
private versions;
|
|
115
|
-
private static versions;
|
|
116
|
-
private providers;
|
|
117
|
-
protected externalProviders: Array<AServiceProvider>;
|
|
118
|
-
protected filteredProviders: Array<string>;
|
|
119
|
-
/**
|
|
120
|
-
* List of registered console commands
|
|
121
|
-
*/
|
|
122
|
-
registeredCommands: (new (app: any, kernel: any) => any)[];
|
|
123
|
-
constructor(basePath: string);
|
|
124
|
-
/**
|
|
125
|
-
* Register core bindings into the container
|
|
126
|
-
*/
|
|
127
|
-
protected registerBaseBindings(): void;
|
|
128
|
-
protected loadOptions(): Promise<void>;
|
|
129
|
-
/**
|
|
130
|
-
* Get all registered providers
|
|
131
|
-
*/
|
|
132
|
-
getRegisteredProviders(): ServiceProvider[];
|
|
133
|
-
/**
|
|
134
|
-
* Load default and optional providers dynamically
|
|
135
|
-
*
|
|
136
|
-
* Auto-Registration Behavior
|
|
137
|
-
*
|
|
138
|
-
* Minimal App: Loads only core, config, http, router by default.
|
|
139
|
-
* Full-Stack App: Installs database, mail, queue, cache → they self-register via their providers.
|
|
140
|
-
*/
|
|
141
|
-
protected getConfiguredProviders(): Promise<Array<AServiceProvider>>;
|
|
142
|
-
protected getAllProviders(): Promise<Array<AServiceProvider>>;
|
|
143
|
-
/**
|
|
144
|
-
* Configure and Dynamically register all configured service providers, then boot the app.
|
|
145
|
-
*
|
|
146
|
-
* @param providers All regitererable service providers
|
|
147
|
-
* @param filtered A list of service provider name strings we do not want to register at all cost
|
|
148
|
-
* @param autoRegisterProviders If set to false, service providers will not be auto discovered and registered.
|
|
149
|
-
*
|
|
150
|
-
* @returns
|
|
151
|
-
*/
|
|
152
|
-
quickStartup(providers: Array<AServiceProvider>, filtered?: string[], autoRegisterProviders?: boolean): Promise<this>;
|
|
153
|
-
/**
|
|
154
|
-
* Dynamically register all configured providers
|
|
155
|
-
*
|
|
156
|
-
* @param autoRegister If set to false, service providers will not be auto discovered and registered.
|
|
157
|
-
*/
|
|
158
|
-
registerConfiguredProviders(autoRegister?: boolean): Promise<void>;
|
|
159
|
-
/**
|
|
160
|
-
* Register service providers
|
|
161
|
-
*
|
|
162
|
-
* @param providers
|
|
163
|
-
* @param filtered
|
|
164
|
-
*/
|
|
165
|
-
registerProviders(providers: Array<AServiceProvider>, filtered?: string[]): void;
|
|
166
|
-
/**
|
|
167
|
-
* Register a provider
|
|
168
|
-
*/
|
|
169
|
-
register(provider: ServiceProvider): Promise<void>;
|
|
170
|
-
/**
|
|
171
|
-
* Register the listed service providers.
|
|
172
|
-
*
|
|
173
|
-
* @param commands An array of console commands to register.
|
|
174
|
-
*/
|
|
175
|
-
withCommands(commands: (new (app: any, kernel: any) => any)[]): this;
|
|
176
|
-
/**
|
|
177
|
-
* checks if the application is running in CLI
|
|
178
|
-
*/
|
|
179
|
-
runningInConsole(): boolean;
|
|
180
|
-
getRuntimeEnv(): 'browser' | 'node' | 'unknown';
|
|
181
|
-
/**
|
|
182
|
-
* Boot all service providers after registration
|
|
183
|
-
*/
|
|
184
|
-
boot(): Promise<this>;
|
|
185
|
-
/**
|
|
186
|
-
* Fire up the developement server using the user provided arguments
|
|
187
|
-
*
|
|
188
|
-
* Port will be auto assigned if provided one is not available
|
|
189
|
-
*
|
|
190
|
-
* @param h3App The current H3 app instance
|
|
191
|
-
* @param preferedPort If provided, this will overide the port set in the evironment
|
|
192
|
-
*/
|
|
193
|
-
fire(): Promise<this>;
|
|
194
|
-
fire(h3App: H3, preferredPort?: number): Promise<this>;
|
|
195
|
-
/**
|
|
196
|
-
* Get the base path of the app
|
|
197
|
-
*
|
|
198
|
-
* @returns
|
|
199
|
-
*/
|
|
200
|
-
getBasePath(): string;
|
|
201
|
-
/**
|
|
202
|
-
* Dynamically retrieves a path property from the class.
|
|
203
|
-
* Any property ending with "Path" is accessible automatically.
|
|
204
|
-
*
|
|
205
|
-
* @param name - The base name of the path property
|
|
206
|
-
* @returns
|
|
207
|
-
*/
|
|
208
|
-
getPath(name: IPathName, suffix?: string): string;
|
|
209
|
-
/**
|
|
210
|
-
* Programatically set the paths.
|
|
211
|
-
*
|
|
212
|
-
* @param name - The base name of the path property
|
|
213
|
-
* @param path - The new path
|
|
214
|
-
* @returns
|
|
215
|
-
*/
|
|
216
|
-
setPath(name: IPathName, path: string): void;
|
|
217
|
-
/**
|
|
218
|
-
* Returns the installed version of the system core and typescript.
|
|
219
|
-
*
|
|
220
|
-
* @returns
|
|
221
|
-
*/
|
|
222
|
-
getVersion(key: string): string;
|
|
223
|
-
/**
|
|
224
|
-
* Returns the installed version of the system core and typescript.
|
|
225
|
-
*
|
|
226
|
-
* @returns
|
|
227
|
-
*/
|
|
228
|
-
static getVersion(key: string): string;
|
|
229
|
-
}
|
|
230
|
-
//#endregion
|
|
231
|
-
//#region src/Contracts/H3ravelContract.d.ts
|
|
232
|
-
interface EntryConfig {
|
|
233
|
-
/**
|
|
234
|
-
* @param h3 You can provide your own `H3` app instance, this is usefull when `@h3ravel/http`
|
|
235
|
-
* is not installed.
|
|
236
|
-
*/
|
|
237
|
-
h3?: H3;
|
|
238
|
-
/**
|
|
239
|
-
* Determines if we should initialize the app on call.
|
|
240
|
-
*
|
|
241
|
-
* @default false
|
|
242
|
-
*/
|
|
243
|
-
initialize?: boolean;
|
|
244
|
-
/**
|
|
245
|
-
* Determines if service providers should be auto discovered and registered or not.
|
|
246
|
-
*
|
|
247
|
-
* @default false
|
|
248
|
-
*/
|
|
249
|
-
autoload?: boolean;
|
|
250
|
-
/**
|
|
251
|
-
* A list of service provider name strings we do not want to register at all cost
|
|
252
|
-
*
|
|
253
|
-
* @default []
|
|
254
|
-
*/
|
|
255
|
-
filteredProviders?: string[];
|
|
256
|
-
}
|
|
257
|
-
//#endregion
|
|
258
|
-
//#region src/Controller.d.ts
|
|
259
|
-
/**
|
|
260
|
-
* Base controller class
|
|
261
|
-
*/
|
|
262
|
-
declare abstract class Controller implements IController {
|
|
263
|
-
protected app: Application;
|
|
264
|
-
constructor(app: Application);
|
|
265
|
-
show?(..._ctx: any[]): any;
|
|
266
|
-
index?(..._ctx: any[]): any;
|
|
267
|
-
store?(..._ctx: any[]): any;
|
|
268
|
-
update?(..._ctx: any[]): any;
|
|
269
|
-
destroy?(..._ctx: any[]): any;
|
|
270
|
-
}
|
|
271
|
-
//#endregion
|
|
272
|
-
//#region src/Di/ContainerResolver.d.ts
|
|
273
|
-
declare class ContainerResolver {
|
|
274
|
-
private app;
|
|
275
|
-
constructor(app: Application);
|
|
276
|
-
resolveMethodParams<I extends Record<string, any>>(instance: I, method: keyof I, ..._default: any[]): Promise<I>;
|
|
277
|
-
static isClass(C: any): boolean;
|
|
278
|
-
}
|
|
279
|
-
//#endregion
|
|
280
|
-
//#region src/Di/Inject.d.ts
|
|
281
|
-
declare function Inject(...dependencies: string[]): (target: any) => void;
|
|
282
|
-
/**
|
|
283
|
-
* Allows binding dependencies to both class and class methods
|
|
284
|
-
*
|
|
285
|
-
* @returns
|
|
286
|
-
*/
|
|
287
|
-
declare function Injectable(): ClassDecorator & MethodDecorator;
|
|
288
|
-
//#endregion
|
|
289
|
-
//#region src/Exceptions/ConfigException.d.ts
|
|
290
|
-
declare class ConfigException extends Error {
|
|
291
|
-
key: string;
|
|
292
|
-
constructor(key: string, type?: 'any' | 'config' | 'env', cause?: unknown);
|
|
293
|
-
}
|
|
294
|
-
//#endregion
|
|
295
|
-
//#region src/H3ravel.d.ts
|
|
296
|
-
/**
|
|
297
|
-
* Simple global entry point for H3ravel applications
|
|
298
|
-
*
|
|
299
|
-
* @param providers
|
|
300
|
-
* @param basePath
|
|
301
|
-
* @param callback
|
|
302
|
-
*/
|
|
303
|
-
declare const h3ravel: (
|
|
304
|
-
/**
|
|
305
|
-
* List of intial service providers to register with your app
|
|
306
|
-
*/
|
|
307
|
-
providers?: Exclude<OServiceProvider, "app" | "commands">[],
|
|
308
|
-
/**
|
|
309
|
-
* Entry path of your app
|
|
310
|
-
*/
|
|
311
|
-
basePath?: string,
|
|
312
|
-
/**
|
|
313
|
-
* Configuration option to pass to the initializer
|
|
314
|
-
*/
|
|
315
|
-
config?: EntryConfig,
|
|
316
|
-
/**
|
|
317
|
-
* final middleware function to call once the server is fired up
|
|
318
|
-
*/
|
|
319
|
-
middleware?: (ctx: HttpContext) => Promise<unknown>) => Promise<Application>;
|
|
320
|
-
//#endregion
|
|
321
|
-
//#region src/Http/Kernel.d.ts
|
|
322
|
-
/**
|
|
323
|
-
* Kernel class handles middleware execution and response transformations.
|
|
324
|
-
* It acts as the core middleware pipeline for HTTP requests.
|
|
325
|
-
*/
|
|
326
|
-
declare class Kernel {
|
|
327
|
-
protected context: (event: H3Event) => HttpContext;
|
|
328
|
-
protected middleware: IMiddleware[];
|
|
329
|
-
/**
|
|
330
|
-
* @param context - A factory function that converts an H3Event into an HttpContext.
|
|
331
|
-
* @param middleware - An array of middleware classes that will be executed in sequence.
|
|
332
|
-
*/
|
|
333
|
-
constructor(context: (event: H3Event) => HttpContext, middleware?: IMiddleware[]);
|
|
334
|
-
/**
|
|
335
|
-
* Handles an incoming request and passes it through middleware before invoking the next handler.
|
|
336
|
-
*
|
|
337
|
-
* @param event - The raw H3 event object.
|
|
338
|
-
* @param next - A callback function that represents the next layer (usually the controller or final handler).
|
|
339
|
-
* @returns A promise resolving to the result of the request pipeline.
|
|
340
|
-
*/
|
|
341
|
-
handle(event: H3Event, next: (ctx: HttpContext) => Promise<unknown>): Promise<unknown>;
|
|
342
|
-
/**
|
|
343
|
-
* Sequentially runs middleware in the order they were registered.
|
|
344
|
-
*
|
|
345
|
-
* @param context - The standardized HttpContext.
|
|
346
|
-
* @param next - Callback to execute when middleware completes.
|
|
347
|
-
* @returns A promise resolving to the final handler's result.
|
|
348
|
-
*/
|
|
349
|
-
private runMiddleware;
|
|
350
|
-
/**
|
|
351
|
-
* Utility function to determine if a value is a plain object or array.
|
|
352
|
-
*
|
|
353
|
-
* @param value - The value to check.
|
|
354
|
-
* @returns True if the value is a plain object or array, otherwise false.
|
|
355
|
-
*/
|
|
356
|
-
private isPlainObject;
|
|
357
|
-
}
|
|
358
|
-
//#endregion
|
|
359
|
-
//#region src/ProviderRegistry.d.ts
|
|
360
|
-
type ProviderCtor = (new (_app: Application) => ServiceProvider) & Partial<ServiceProvider>;
|
|
361
|
-
declare class ProviderRegistry {
|
|
362
|
-
private static providers;
|
|
363
|
-
private static priorityMap;
|
|
364
|
-
private static filteredProviders;
|
|
365
|
-
private static sortable;
|
|
366
|
-
/**
|
|
367
|
-
* Set wether providers should be sorted or not.
|
|
368
|
-
*
|
|
369
|
-
* @returns
|
|
370
|
-
*/
|
|
371
|
-
static setSortable(sort?: boolean): void;
|
|
372
|
-
/**
|
|
373
|
-
* Get a unique identifier for the Provider.
|
|
374
|
-
*
|
|
375
|
-
* @param provider
|
|
376
|
-
* @returns
|
|
377
|
-
*/
|
|
378
|
-
private static getKey;
|
|
379
|
-
/**
|
|
380
|
-
* Register one or more providers.
|
|
381
|
-
* Duplicate constructors will be ignored.
|
|
382
|
-
*
|
|
383
|
-
* @param providers
|
|
384
|
-
* @returns
|
|
385
|
-
*/
|
|
386
|
-
static register(...providers: ProviderCtor[]): void;
|
|
387
|
-
/**
|
|
388
|
-
* Bulk register providers from an array.
|
|
389
|
-
*
|
|
390
|
-
* @param providers
|
|
391
|
-
* @returns
|
|
392
|
-
*/
|
|
393
|
-
static registerMany(providers: ProviderCtor[]): void;
|
|
394
|
-
/**
|
|
395
|
-
* Set the filtered providers.
|
|
396
|
-
*
|
|
397
|
-
* @returns
|
|
398
|
-
*/
|
|
399
|
-
static setFiltered(filtered: string[]): void;
|
|
400
|
-
/**
|
|
401
|
-
* Resolve (instantiate) all providers with the given application or Service Container.
|
|
402
|
-
*
|
|
403
|
-
* @param app
|
|
404
|
-
* @returns
|
|
405
|
-
*/
|
|
406
|
-
static resolve(app: Application, useServiceContainer?: boolean): Promise<ServiceProvider[]>;
|
|
407
|
-
/**
|
|
408
|
-
* Sort the service providers
|
|
409
|
-
*
|
|
410
|
-
* @param providers
|
|
411
|
-
* @returns
|
|
412
|
-
*/
|
|
413
|
-
static sort(providers: ProviderCtor[]): ProviderCtor[];
|
|
414
|
-
/**
|
|
415
|
-
* Sort service providers
|
|
416
|
-
*/
|
|
417
|
-
static doSort(): void;
|
|
418
|
-
/**
|
|
419
|
-
* Log the service providers in a table
|
|
420
|
-
*
|
|
421
|
-
* @param priorityMap
|
|
422
|
-
*/
|
|
423
|
-
static log<P extends ServiceProvider>(providers?: Array<P> | Map<string, P>): void;
|
|
424
|
-
/**
|
|
425
|
-
* Get all registered providers as an array.
|
|
426
|
-
*
|
|
427
|
-
* @returns
|
|
428
|
-
*/
|
|
429
|
-
static all(): ProviderCtor[];
|
|
430
|
-
/**
|
|
431
|
-
* Check if a provider is already registered.
|
|
432
|
-
*
|
|
433
|
-
* @param provider
|
|
434
|
-
* @returns
|
|
435
|
-
*/
|
|
436
|
-
static has(provider: ProviderCtor): boolean;
|
|
437
|
-
/**
|
|
438
|
-
* Automatically search for and discover service providers in packages.
|
|
439
|
-
*
|
|
440
|
-
* @param autoRegister
|
|
441
|
-
* @returns
|
|
442
|
-
*/
|
|
443
|
-
static discoverProviders(autoRegister?: boolean): Promise<ProviderCtor[]>;
|
|
444
|
-
/**
|
|
445
|
-
* Get the content of the package.json file
|
|
446
|
-
*
|
|
447
|
-
* @param manifestPath
|
|
448
|
-
* @returns
|
|
449
|
-
*/
|
|
450
|
-
private static getManifest;
|
|
451
|
-
}
|
|
452
|
-
//#endregion
|
|
453
|
-
//#region src/Providers/CoreServiceProvider.d.ts
|
|
454
|
-
/**
|
|
455
|
-
* Bootstraps core services and bindings.
|
|
456
|
-
*
|
|
457
|
-
* Bind essential services to the container (logger, config repository).
|
|
458
|
-
* Register app-level singletons.
|
|
459
|
-
* Set up exception handling.
|
|
460
|
-
*
|
|
461
|
-
* Auto-Registered
|
|
462
|
-
*/
|
|
463
|
-
declare class CoreServiceProvider extends ServiceProvider {
|
|
464
|
-
static priority: number;
|
|
465
|
-
register(): void;
|
|
466
|
-
boot(): void | Promise<void>;
|
|
467
|
-
}
|
|
468
|
-
//#endregion
|
|
469
|
-
//#region src/Registerer.d.ts
|
|
470
|
-
declare class Registerer {
|
|
471
|
-
private app;
|
|
472
|
-
constructor(app: Application);
|
|
473
|
-
static register(app: Application): void;
|
|
474
|
-
bootRegister(): void;
|
|
475
|
-
private appPath;
|
|
476
|
-
private basePath;
|
|
477
|
-
private publicPath;
|
|
478
|
-
private storagePath;
|
|
479
|
-
private databasePath;
|
|
480
|
-
}
|
|
481
|
-
//#endregion
|
|
482
|
-
export { AServiceProvider, Application, ConfigException, Container, ContainerResolver, Controller, CoreServiceProvider, EntryConfig, Inject, Injectable, Kernel, OServiceProvider, ProviderRegistry, Registerer, ServiceProvider, ServiceProviderConstructor, h3ravel };
|