@h3ravel/core 0.1.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/LICENSE +21 -0
- package/dist/chunk-UZGBH6AC.js +776 -0
- package/dist/chunk-UZGBH6AC.js.map +1 -0
- package/dist/index.cjs +1860 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +352 -0
- package/dist/index.d.ts +352 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/src-E5IZSMT7.js +223 -0
- package/dist/src-E5IZSMT7.js.map +1 -0
- package/dist/src-HATPJSC4.js +19 -0
- package/dist/src-HATPJSC4.js.map +1 -0
- package/dist/src-KWAEFHNO.js +528 -0
- package/dist/src-KWAEFHNO.js.map +1 -0
- package/package.json +29 -0
- package/src/Application.ts +164 -0
- package/src/Container.ts +71 -0
- package/src/Contracts/.gitkeep +0 -0
- package/src/Contracts/BindingsContract.ts +37 -0
- package/src/Controller.ts +20 -0
- package/src/Exceptions/Handler.ts +1 -0
- package/src/Http/Kernel.ts +47 -0
- package/src/Providers/AppServiceProvider.ts +18 -0
- package/src/Providers/ViewServiceProvider.ts +19 -0
- package/src/ServiceProvider.ts +21 -0
- package/src/Utils/PathLoader.ts +46 -0
- package/src/index.ts +14 -0
- package/tests/.gitkeep +0 -0
- package/tsconfig.json +8 -0
- package/vite.config.ts +9 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import { H3Event, H3, Middleware as Middleware$1, MiddlewareOptions, serve } from 'h3';
|
|
2
|
+
import { Edge } from 'edge.js';
|
|
3
|
+
|
|
4
|
+
type PathName = 'views' | 'routes' | 'assets' | 'base' | 'public' | 'storage' | 'config';
|
|
5
|
+
declare class PathLoader {
|
|
6
|
+
private paths;
|
|
7
|
+
/**
|
|
8
|
+
* Dynamically retrieves a path property from the class.
|
|
9
|
+
* Any property ending with "Path" is accessible automatically.
|
|
10
|
+
*
|
|
11
|
+
* @param name - The base name of the path property
|
|
12
|
+
* @param base - The base path to include to the path
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
getPath(name: PathName, base?: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Programatically set the paths.
|
|
18
|
+
*
|
|
19
|
+
* @param name - The base name of the path property
|
|
20
|
+
* @param path - The new path
|
|
21
|
+
* @param base - The base path to include to the path
|
|
22
|
+
*/
|
|
23
|
+
setPath(name: PathName, path: string, base?: string): void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Builds "nested.key" paths for autocompletion
|
|
28
|
+
*/
|
|
29
|
+
type DotNestedKeys<T> = {
|
|
30
|
+
[K in keyof T & string]: T[K] extends object ? `${K}` | `${K}.${DotNestedKeys<T[K]>}` : `${K}`;
|
|
31
|
+
}[keyof T & string];
|
|
32
|
+
/**
|
|
33
|
+
* Retrieves type at a given dot-path
|
|
34
|
+
*/
|
|
35
|
+
type DotNestedValue<T, Path extends string> = Path extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? DotNestedValue<T[Key], Rest> : never : Path extends keyof T ? T[Path] : never;
|
|
36
|
+
|
|
37
|
+
declare class Request {
|
|
38
|
+
private readonly event;
|
|
39
|
+
constructor(event: H3Event);
|
|
40
|
+
/**
|
|
41
|
+
* Get all input data (query + body).
|
|
42
|
+
*/
|
|
43
|
+
all<T = Record<string, unknown>>(): Promise<T>;
|
|
44
|
+
/**
|
|
45
|
+
* Get a single input field from query or body.
|
|
46
|
+
*/
|
|
47
|
+
input<T = unknown>(key: string, defaultValue?: T): Promise<T>;
|
|
48
|
+
/**
|
|
49
|
+
* Get route parameters.
|
|
50
|
+
*/
|
|
51
|
+
params<T = Record<string, string>>(): T;
|
|
52
|
+
/**
|
|
53
|
+
* Get query parameters.
|
|
54
|
+
*/
|
|
55
|
+
query<T = Record<string, string>>(): T;
|
|
56
|
+
/**
|
|
57
|
+
* Get the base event
|
|
58
|
+
*/
|
|
59
|
+
getEvent(): H3Event;
|
|
60
|
+
getEvent<K extends DotNestedKeys<H3Event>>(key: K): DotNestedValue<H3Event, K>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
declare class Response {
|
|
64
|
+
private readonly event;
|
|
65
|
+
private statusCode;
|
|
66
|
+
private headers;
|
|
67
|
+
constructor(event: H3Event);
|
|
68
|
+
/**
|
|
69
|
+
* Set HTTP status code.
|
|
70
|
+
*/
|
|
71
|
+
setStatusCode(code: number): this;
|
|
72
|
+
/**
|
|
73
|
+
* Set a header.
|
|
74
|
+
*/
|
|
75
|
+
setHeader(name: string, value: string): this;
|
|
76
|
+
html(content: string): string;
|
|
77
|
+
/**
|
|
78
|
+
* Send a JSON response.
|
|
79
|
+
*/
|
|
80
|
+
json<T = unknown>(data: T): T;
|
|
81
|
+
/**
|
|
82
|
+
* Send plain text.
|
|
83
|
+
*/
|
|
84
|
+
text(data: string): string;
|
|
85
|
+
/**
|
|
86
|
+
* Redirect to another URL.
|
|
87
|
+
*/
|
|
88
|
+
redirect(url: string, status?: number): string;
|
|
89
|
+
/**
|
|
90
|
+
* Apply headers before sending response.
|
|
91
|
+
*/
|
|
92
|
+
private applyHeaders;
|
|
93
|
+
/**
|
|
94
|
+
* Get the base event
|
|
95
|
+
*/
|
|
96
|
+
getEvent(): H3Event;
|
|
97
|
+
getEvent<K extends DotNestedKeys<H3Event>>(key: K): DotNestedValue<H3Event, K>;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
interface HttpContext {
|
|
101
|
+
request: Request;
|
|
102
|
+
response: Response;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
declare abstract class Middleware {
|
|
106
|
+
abstract handle(context: HttpContext, next: () => Promise<unknown>): Promise<unknown>;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Defines the contract for all controllers.
|
|
111
|
+
* Any controller implementing this must define these methods.
|
|
112
|
+
*/
|
|
113
|
+
interface IController {
|
|
114
|
+
show(ctx: HttpContext): any;
|
|
115
|
+
index(ctx: HttpContext): any;
|
|
116
|
+
store(ctx: HttpContext): any;
|
|
117
|
+
update(ctx: HttpContext): any;
|
|
118
|
+
destroy(ctx: HttpContext): any;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
type EventHandler = (ctx: HttpContext) => unknown;
|
|
122
|
+
declare class Router {
|
|
123
|
+
private h3App;
|
|
124
|
+
private app;
|
|
125
|
+
private routes;
|
|
126
|
+
private groupPrefix;
|
|
127
|
+
private groupMiddleware;
|
|
128
|
+
constructor(h3App: H3, app: Application);
|
|
129
|
+
/**
|
|
130
|
+
* Route Resolver
|
|
131
|
+
*
|
|
132
|
+
* @param handler
|
|
133
|
+
* @param middleware
|
|
134
|
+
* @returns
|
|
135
|
+
*/
|
|
136
|
+
private resolveHandler;
|
|
137
|
+
/**
|
|
138
|
+
* Add a route to the stack
|
|
139
|
+
*
|
|
140
|
+
* @param method
|
|
141
|
+
* @param path
|
|
142
|
+
* @param handler
|
|
143
|
+
* @param name
|
|
144
|
+
* @param middleware
|
|
145
|
+
*/
|
|
146
|
+
private addRoute;
|
|
147
|
+
private resolveControllerOrHandler;
|
|
148
|
+
get(path: string, handler: EventHandler | (new (...args: any[]) => Controller), methodName?: string, name?: string, middleware?: Middleware[]): void;
|
|
149
|
+
post(path: string, handler: EventHandler | (new (...args: any[]) => Controller), methodName?: string, name?: string, middleware?: Middleware[]): void;
|
|
150
|
+
put(path: string, handler: EventHandler | (new (...args: any[]) => Controller), methodName?: string, name?: string, middleware?: Middleware[]): void;
|
|
151
|
+
delete(path: string, handler: EventHandler | (new (...args: any[]) => Controller), methodName?: string, name?: string, middleware?: Middleware[]): void;
|
|
152
|
+
/**
|
|
153
|
+
* API Resource support
|
|
154
|
+
*
|
|
155
|
+
* @param path
|
|
156
|
+
* @param controller
|
|
157
|
+
*/
|
|
158
|
+
apiResource(path: string, Controller: new (app: Application) => Controller, middleware?: Middleware[]): void;
|
|
159
|
+
/**
|
|
160
|
+
* Named route URL generator
|
|
161
|
+
*
|
|
162
|
+
* @param name
|
|
163
|
+
* @param params
|
|
164
|
+
* @returns
|
|
165
|
+
*/
|
|
166
|
+
route(name: string, params?: Record<string, string>): string | undefined;
|
|
167
|
+
/**
|
|
168
|
+
* Grouping
|
|
169
|
+
*
|
|
170
|
+
* @param options
|
|
171
|
+
* @param callback
|
|
172
|
+
*/
|
|
173
|
+
group(options: {
|
|
174
|
+
prefix?: string;
|
|
175
|
+
middleware?: EventHandler[];
|
|
176
|
+
}, callback: () => void): void;
|
|
177
|
+
middleware(path: string, handler: Middleware$1, opts?: MiddlewareOptions): void;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
type RemoveIndexSignature<T> = {
|
|
181
|
+
[K in keyof T as string extends K ? never : number extends K ? never : K]: T[K];
|
|
182
|
+
};
|
|
183
|
+
type Bindings = {
|
|
184
|
+
[key: string]: any;
|
|
185
|
+
env<T extends string>(): NodeJS.ProcessEnv;
|
|
186
|
+
env<T extends string>(key: T, def?: any): any;
|
|
187
|
+
view: Edge;
|
|
188
|
+
asset(key: string, def?: string): string;
|
|
189
|
+
router: Router;
|
|
190
|
+
config: {
|
|
191
|
+
get<X extends Record<string, any>>(): X;
|
|
192
|
+
get<X extends Record<string, any>, T extends Extract<keyof X, string>>(key: T, def?: any): X[T];
|
|
193
|
+
set<T extends string>(key: T, value: any): void;
|
|
194
|
+
load?(): any;
|
|
195
|
+
};
|
|
196
|
+
'http.app': H3;
|
|
197
|
+
'path.base': string;
|
|
198
|
+
'app.paths': PathLoader;
|
|
199
|
+
'http.serve': typeof serve;
|
|
200
|
+
};
|
|
201
|
+
type UseKey = keyof RemoveIndexSignature<Bindings>;
|
|
202
|
+
|
|
203
|
+
declare class Container {
|
|
204
|
+
private bindings;
|
|
205
|
+
private singletons;
|
|
206
|
+
/**
|
|
207
|
+
* Bind a transient service to the container
|
|
208
|
+
*/
|
|
209
|
+
bind<T>(key: new (...args: any[]) => T, factory: () => T): void;
|
|
210
|
+
bind<T extends UseKey>(key: T, factory: () => Bindings[T]): void;
|
|
211
|
+
/**
|
|
212
|
+
* Bind a singleton service to the container
|
|
213
|
+
*/
|
|
214
|
+
singleton<T extends UseKey>(key: T | (new (..._args: any[]) => Bindings[T]), factory: () => Bindings[T]): void;
|
|
215
|
+
/**
|
|
216
|
+
* Resolve a service from the container
|
|
217
|
+
*/
|
|
218
|
+
make<T extends UseKey>(key: T | (new (..._args: any[]) => Bindings[T])): Bindings[T];
|
|
219
|
+
/**
|
|
220
|
+
* Automatically build a class with constructor dependency injection
|
|
221
|
+
*/
|
|
222
|
+
private build;
|
|
223
|
+
/**
|
|
224
|
+
* Check if a service is registered
|
|
225
|
+
*/
|
|
226
|
+
has(key: UseKey): boolean;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
declare abstract class ServiceProvider {
|
|
230
|
+
protected app: Application;
|
|
231
|
+
constructor(app: Application);
|
|
232
|
+
/**
|
|
233
|
+
* Register bindings to the container.
|
|
234
|
+
* Runs before boot().
|
|
235
|
+
*/
|
|
236
|
+
abstract register(): void | Promise<void>;
|
|
237
|
+
/**
|
|
238
|
+
* Perform post-registration booting of services.
|
|
239
|
+
* Runs after all providers have been registered.
|
|
240
|
+
*/
|
|
241
|
+
boot?(): void | Promise<void>;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
declare class Application extends Container {
|
|
245
|
+
paths: PathLoader;
|
|
246
|
+
private booted;
|
|
247
|
+
private versions;
|
|
248
|
+
private basePath;
|
|
249
|
+
private providers;
|
|
250
|
+
protected externalProviders: Array<new (_app: Application) => ServiceProvider>;
|
|
251
|
+
constructor(basePath: string);
|
|
252
|
+
/**
|
|
253
|
+
* Register core bindings into the container
|
|
254
|
+
*/
|
|
255
|
+
protected registerBaseBindings(): void;
|
|
256
|
+
/**
|
|
257
|
+
* Dynamically register all configured providers
|
|
258
|
+
*/
|
|
259
|
+
registerConfiguredProviders(): Promise<void>;
|
|
260
|
+
protected loadOptions(): Promise<void>;
|
|
261
|
+
/**
|
|
262
|
+
* Load default and optional providers dynamically
|
|
263
|
+
*
|
|
264
|
+
* Auto-Registration Behavior
|
|
265
|
+
*
|
|
266
|
+
* Minimal App: Loads only core, config, http, router by default.
|
|
267
|
+
* Full-Stack App: Installs database, mail, queue, cache → they self-register via their providers.
|
|
268
|
+
*/
|
|
269
|
+
protected getConfiguredProviders(): Promise<Array<new (_app: Application) => ServiceProvider>>;
|
|
270
|
+
protected getAllProviders(): Promise<Array<new (_app: Application) => ServiceProvider>>;
|
|
271
|
+
registerProviders(providers: Array<new (_app: Application) => ServiceProvider>): void;
|
|
272
|
+
/**
|
|
273
|
+
* Register a provider
|
|
274
|
+
*/
|
|
275
|
+
register(provider: ServiceProvider): Promise<void>;
|
|
276
|
+
/**
|
|
277
|
+
* Boot all providers after registration
|
|
278
|
+
*/
|
|
279
|
+
boot(): Promise<void>;
|
|
280
|
+
/**
|
|
281
|
+
* Attempt to dynamically import an optional module
|
|
282
|
+
*/
|
|
283
|
+
private safeImport;
|
|
284
|
+
/**
|
|
285
|
+
* Get the base path of the app
|
|
286
|
+
*
|
|
287
|
+
* @returns
|
|
288
|
+
*/
|
|
289
|
+
getBasePath(): string;
|
|
290
|
+
/**
|
|
291
|
+
* Dynamically retrieves a path property from the class.
|
|
292
|
+
* Any property ending with "Path" is accessible automatically.
|
|
293
|
+
*
|
|
294
|
+
* @param name - The base name of the path property
|
|
295
|
+
* @returns
|
|
296
|
+
*/
|
|
297
|
+
getPath(name: Parameters<PathLoader['setPath']>[0], pth?: string): string;
|
|
298
|
+
/**
|
|
299
|
+
* Programatically set the paths.
|
|
300
|
+
*
|
|
301
|
+
* @param name - The base name of the path property
|
|
302
|
+
* @param path - The new path
|
|
303
|
+
* @returns
|
|
304
|
+
*/
|
|
305
|
+
setPath(name: Parameters<PathLoader['setPath']>[0], path: string): void;
|
|
306
|
+
/**
|
|
307
|
+
* Returns the installed version of the system core and typescript.
|
|
308
|
+
*
|
|
309
|
+
* @returns
|
|
310
|
+
*/
|
|
311
|
+
getVersion(key: 'app' | 'ts'): string;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Base controller class
|
|
316
|
+
*/
|
|
317
|
+
declare abstract class Controller implements IController {
|
|
318
|
+
protected app: Application;
|
|
319
|
+
constructor(app: Application);
|
|
320
|
+
show(_ctx: HttpContext): any;
|
|
321
|
+
index(_ctx: HttpContext): any;
|
|
322
|
+
store(_ctx: HttpContext): any;
|
|
323
|
+
update(_ctx: HttpContext): any;
|
|
324
|
+
destroy(_ctx: HttpContext): any;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
declare class Kernel {
|
|
328
|
+
private middleware;
|
|
329
|
+
constructor(middleware?: Middleware[]);
|
|
330
|
+
handle(event: H3Event, next: (ctx: HttpContext) => Promise<unknown>): Promise<unknown>;
|
|
331
|
+
private runMiddleware;
|
|
332
|
+
private isPlainObject;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Bootstraps core services and bindings.
|
|
337
|
+
*
|
|
338
|
+
* Bind essential services to the container (logger, config repository).
|
|
339
|
+
* Register app-level singletons.
|
|
340
|
+
* Set up exception handling.
|
|
341
|
+
*
|
|
342
|
+
* Auto-Registered
|
|
343
|
+
*/
|
|
344
|
+
declare class AppServiceProvider extends ServiceProvider {
|
|
345
|
+
register(): void;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
declare class ViewServiceProvider extends ServiceProvider {
|
|
349
|
+
register(): void;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export { AppServiceProvider, Application, type Bindings, Container, Controller, Kernel, PathLoader, ServiceProvider, type UseKey, ViewServiceProvider };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AppServiceProvider,
|
|
3
|
+
Application,
|
|
4
|
+
Container,
|
|
5
|
+
Controller,
|
|
6
|
+
Kernel,
|
|
7
|
+
PathLoader,
|
|
8
|
+
ServiceProvider,
|
|
9
|
+
ViewServiceProvider
|
|
10
|
+
} from "./chunk-UZGBH6AC.js";
|
|
11
|
+
export {
|
|
12
|
+
AppServiceProvider,
|
|
13
|
+
Application,
|
|
14
|
+
Container,
|
|
15
|
+
Controller,
|
|
16
|
+
Kernel,
|
|
17
|
+
PathLoader,
|
|
18
|
+
ServiceProvider,
|
|
19
|
+
ViewServiceProvider
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Controller,
|
|
3
|
+
Kernel,
|
|
4
|
+
ServiceProvider,
|
|
5
|
+
__name,
|
|
6
|
+
afterLast,
|
|
7
|
+
before
|
|
8
|
+
} from "./chunk-UZGBH6AC.js";
|
|
9
|
+
|
|
10
|
+
// ../router/src/Router.ts
|
|
11
|
+
var Router = class {
|
|
12
|
+
static {
|
|
13
|
+
__name(this, "Router");
|
|
14
|
+
}
|
|
15
|
+
h3App;
|
|
16
|
+
app;
|
|
17
|
+
routes = [];
|
|
18
|
+
groupPrefix = "";
|
|
19
|
+
groupMiddleware = [];
|
|
20
|
+
constructor(h3App, app) {
|
|
21
|
+
this.h3App = h3App;
|
|
22
|
+
this.app = app;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Route Resolver
|
|
26
|
+
*
|
|
27
|
+
* @param handler
|
|
28
|
+
* @param middleware
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
resolveHandler(handler, middleware = []) {
|
|
32
|
+
return async (event) => {
|
|
33
|
+
const kernel = new Kernel(middleware);
|
|
34
|
+
return kernel.handle(event, (ctx) => Promise.resolve(handler(ctx)));
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Add a route to the stack
|
|
39
|
+
*
|
|
40
|
+
* @param method
|
|
41
|
+
* @param path
|
|
42
|
+
* @param handler
|
|
43
|
+
* @param name
|
|
44
|
+
* @param middleware
|
|
45
|
+
*/
|
|
46
|
+
addRoute(method, path2, handler, name, middleware = []) {
|
|
47
|
+
const fullPath = `${this.groupPrefix}${path2}`.replace(/\/+/g, "/");
|
|
48
|
+
this.routes.push({
|
|
49
|
+
method,
|
|
50
|
+
path: fullPath,
|
|
51
|
+
name,
|
|
52
|
+
handler
|
|
53
|
+
});
|
|
54
|
+
this.h3App[method](fullPath, this.resolveHandler(handler, middleware));
|
|
55
|
+
}
|
|
56
|
+
resolveControllerOrHandler(handler, methodName) {
|
|
57
|
+
if (typeof handler === "function" && handler.prototype instanceof Controller) {
|
|
58
|
+
return (ctx) => {
|
|
59
|
+
const controller = new handler(this.app);
|
|
60
|
+
const action = methodName || "index";
|
|
61
|
+
if (typeof controller[action] !== "function") {
|
|
62
|
+
throw new Error(`Method "${action}" not found on controller ${handler.name}`);
|
|
63
|
+
}
|
|
64
|
+
return controller[action](ctx);
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return handler;
|
|
68
|
+
}
|
|
69
|
+
get(path2, handler, methodName, name, middleware = []) {
|
|
70
|
+
this.addRoute("get", path2, this.resolveControllerOrHandler(handler, methodName), name, middleware);
|
|
71
|
+
}
|
|
72
|
+
post(path2, handler, methodName, name, middleware = []) {
|
|
73
|
+
this.addRoute("post", path2, this.resolveControllerOrHandler(handler, methodName), name, middleware);
|
|
74
|
+
}
|
|
75
|
+
put(path2, handler, methodName, name, middleware = []) {
|
|
76
|
+
this.addRoute("put", path2, this.resolveControllerOrHandler(handler, methodName), name, middleware);
|
|
77
|
+
}
|
|
78
|
+
delete(path2, handler, methodName, name, middleware = []) {
|
|
79
|
+
this.addRoute("delete", path2, this.resolveControllerOrHandler(handler, methodName), name, middleware);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* API Resource support
|
|
83
|
+
*
|
|
84
|
+
* @param path
|
|
85
|
+
* @param controller
|
|
86
|
+
*/
|
|
87
|
+
apiResource(path2, Controller2, middleware = []) {
|
|
88
|
+
path2 = path2.replace(/\//g, "/");
|
|
89
|
+
const name = afterLast(path2, "/");
|
|
90
|
+
const basePath = `/${path2}`.replace(/\/+/g, "/");
|
|
91
|
+
const controller = new Controller2(this.app);
|
|
92
|
+
this.addRoute("get", basePath, controller.index.bind(controller), `${name}.index`, middleware);
|
|
93
|
+
this.addRoute("post", basePath, controller.store.bind(controller), `${name}.store`, middleware);
|
|
94
|
+
this.addRoute("get", `${basePath}/:id`, controller.show.bind(controller), `${name}.show`, middleware);
|
|
95
|
+
this.addRoute("put", `${basePath}/:id`, controller.update.bind(controller), `${name}.update`, middleware);
|
|
96
|
+
this.addRoute("patch", `${basePath}/:id`, controller.update.bind(controller), `${name}.update`, middleware);
|
|
97
|
+
this.addRoute("delete", `${basePath}/:id`, controller.destroy.bind(controller), `${name}.destroy`, middleware);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Named route URL generator
|
|
101
|
+
*
|
|
102
|
+
* @param name
|
|
103
|
+
* @param params
|
|
104
|
+
* @returns
|
|
105
|
+
*/
|
|
106
|
+
route(name, params = {}) {
|
|
107
|
+
const found = this.routes.find((r) => r.name === name);
|
|
108
|
+
if (!found) return void 0;
|
|
109
|
+
let url = found.path;
|
|
110
|
+
for (const [key, value] of Object.entries(params)) {
|
|
111
|
+
url = url.replace(`:${key}`, value);
|
|
112
|
+
}
|
|
113
|
+
return url;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Grouping
|
|
117
|
+
*
|
|
118
|
+
* @param options
|
|
119
|
+
* @param callback
|
|
120
|
+
*/
|
|
121
|
+
group(options, callback) {
|
|
122
|
+
const prevPrefix = this.groupPrefix;
|
|
123
|
+
const prevMiddleware = [
|
|
124
|
+
...this.groupMiddleware
|
|
125
|
+
];
|
|
126
|
+
this.groupPrefix += options.prefix || "";
|
|
127
|
+
this.groupMiddleware.push(...options.middleware || []);
|
|
128
|
+
callback();
|
|
129
|
+
this.groupPrefix = prevPrefix;
|
|
130
|
+
this.groupMiddleware = prevMiddleware;
|
|
131
|
+
}
|
|
132
|
+
middleware(path2, handler, opts) {
|
|
133
|
+
this.h3App.use(path2, handler, opts);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// ../router/src/Providers/AssetsServiceProvider.ts
|
|
138
|
+
import { readFile, stat } from "fs/promises";
|
|
139
|
+
import { join } from "path";
|
|
140
|
+
import { serveStatic } from "h3";
|
|
141
|
+
import { statSync } from "fs";
|
|
142
|
+
var AssetsServiceProvider = class extends ServiceProvider {
|
|
143
|
+
static {
|
|
144
|
+
__name(this, "AssetsServiceProvider");
|
|
145
|
+
}
|
|
146
|
+
register() {
|
|
147
|
+
const app = this.app.make("router");
|
|
148
|
+
const config = this.app.make("config");
|
|
149
|
+
const fsconfig = config.get("filesystem");
|
|
150
|
+
const publicPath = this.app.getPath("public");
|
|
151
|
+
app.middleware(`/${fsconfig.public_mask}/**`, (event) => {
|
|
152
|
+
return serveStatic(event, {
|
|
153
|
+
indexNames: [
|
|
154
|
+
"/index.html"
|
|
155
|
+
],
|
|
156
|
+
getContents: /* @__PURE__ */ __name((id) => {
|
|
157
|
+
const newId = id.replace(`/${fsconfig.public_mask}/`, "");
|
|
158
|
+
return readFile(join(before(publicPath, newId), newId));
|
|
159
|
+
}, "getContents"),
|
|
160
|
+
getMeta: /* @__PURE__ */ __name(async (id) => {
|
|
161
|
+
const newId = id.replace(`/${fsconfig.public_mask}/`, "");
|
|
162
|
+
const stats = await stat(join(before(publicPath, newId), newId)).catch(() => {
|
|
163
|
+
});
|
|
164
|
+
if (stats?.isFile()) {
|
|
165
|
+
return {
|
|
166
|
+
size: stats.size,
|
|
167
|
+
mtime: stats.mtimeMs
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}, "getMeta")
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
this.app.singleton("asset", () => {
|
|
174
|
+
return (key, def = "") => {
|
|
175
|
+
try {
|
|
176
|
+
statSync(join(before(publicPath, key), key));
|
|
177
|
+
} catch {
|
|
178
|
+
key = def;
|
|
179
|
+
}
|
|
180
|
+
return join(fsconfig.public_mask, key);
|
|
181
|
+
};
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
// ../router/src/Providers/RouteServiceProvider.ts
|
|
187
|
+
import path from "path";
|
|
188
|
+
import { readdir } from "fs/promises";
|
|
189
|
+
var RouteServiceProvider = class extends ServiceProvider {
|
|
190
|
+
static {
|
|
191
|
+
__name(this, "RouteServiceProvider");
|
|
192
|
+
}
|
|
193
|
+
register() {
|
|
194
|
+
this.app.singleton("router", () => {
|
|
195
|
+
const h3App = this.app.make("http.app");
|
|
196
|
+
return new Router(h3App, this.app);
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Load routes from src/routes
|
|
201
|
+
*/
|
|
202
|
+
async boot() {
|
|
203
|
+
try {
|
|
204
|
+
const routePath = this.app.getPath("routes");
|
|
205
|
+
const files = await readdir(routePath);
|
|
206
|
+
for (let i = 0; i < files.length; i++) {
|
|
207
|
+
const routesModule = await import(path.join(routePath, files[i]));
|
|
208
|
+
if (typeof routesModule.default === "function") {
|
|
209
|
+
const router = this.app.make("router");
|
|
210
|
+
routesModule.default(router);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
} catch (e) {
|
|
214
|
+
console.warn("No web routes found or failed to load:", e);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
export {
|
|
219
|
+
AssetsServiceProvider,
|
|
220
|
+
RouteServiceProvider,
|
|
221
|
+
Router
|
|
222
|
+
};
|
|
223
|
+
//# sourceMappingURL=src-E5IZSMT7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../router/src/Router.ts","../../router/src/Providers/AssetsServiceProvider.ts","../../router/src/Providers/RouteServiceProvider.ts"],"sourcesContent":["import { H3Event, Middleware, MiddlewareOptions, type H3 } from 'h3'\nimport { Application, Controller, Kernel } from '@h3ravel/core'\nimport { Middleware as HttpMiddleware } from '@h3ravel/http'\nimport { HttpContext } from '@h3ravel/http'\nimport { afterLast } from '@h3ravel/support'\n\ntype EventHandler = (ctx: HttpContext) => unknown\n\ninterface RouteDefinition {\n method: string\n path: string\n name?: string\n handler: EventHandler\n}\n\nexport class Router {\n private routes: RouteDefinition[] = []\n private groupPrefix = ''\n private groupMiddleware: EventHandler[] = []\n\n constructor(private h3App: H3, private app: Application) { }\n\n /**\n * Route Resolver\n * \n * @param handler \n * @param middleware \n * @returns \n */\n private resolveHandler (handler: EventHandler, middleware: HttpMiddleware[] = []) {\n return async (event: H3Event) => {\n const kernel = new Kernel(middleware)\n return kernel.handle(event, (ctx) => Promise.resolve(handler(ctx)))\n }\n }\n\n /**\n * Add a route to the stack\n * \n * @param method \n * @param path \n * @param handler \n * @param name \n * @param middleware \n */\n private addRoute (\n method: string,\n path: string,\n handler: EventHandler,\n name?: string,\n middleware: HttpMiddleware[] = []\n ) {\n const fullPath = `${this.groupPrefix}${path}`.replace(/\\/+/g, '/')\n this.routes.push({ method, path: fullPath, name, handler })\n this.h3App[method as 'get'](fullPath, this.resolveHandler(handler, middleware))\n }\n\n private resolveControllerOrHandler (\n handler: EventHandler | (new (...args: any[]) => Controller),\n methodName?: string\n ): EventHandler {\n if (typeof handler === 'function' && (handler as any).prototype instanceof Controller) {\n return (ctx) => {\n const controller = new (handler as new (...args: any[]) => Controller)(this.app)\n const action = (methodName || 'index') as keyof Controller\n\n if (typeof controller[action] !== 'function') {\n throw new Error(`Method \"${action}\" not found on controller ${handler.name}`)\n }\n\n return controller[action](ctx)\n }\n }\n\n return handler as EventHandler\n }\n\n\n get (\n path: string,\n handler: EventHandler | (new (...args: any[]) => Controller),\n methodName?: string, name?: string, middleware: HttpMiddleware[] = []\n ) {\n this.addRoute('get', path, this.resolveControllerOrHandler(handler, methodName), name, middleware)\n }\n\n post (\n path: string,\n handler: EventHandler | (new (...args: any[]) => Controller),\n methodName?: string, name?: string, middleware: HttpMiddleware[] = []\n ) {\n this.addRoute('post', path, this.resolveControllerOrHandler(handler, methodName), name, middleware)\n }\n\n put (\n path: string,\n handler: EventHandler | (new (...args: any[]) => Controller),\n methodName?: string, name?: string, middleware: HttpMiddleware[] = []\n ) {\n this.addRoute('put', path, this.resolveControllerOrHandler(handler, methodName), name, middleware)\n }\n\n delete (\n path: string,\n handler: EventHandler | (new (...args: any[]) => Controller),\n methodName?: string, name?: string, middleware: HttpMiddleware[] = []\n ) {\n this.addRoute('delete', path, this.resolveControllerOrHandler(handler, methodName), name, middleware)\n }\n\n /**\n * API Resource support \n * \n * @param path \n * @param controller \n */\n apiResource (\n path: string,\n Controller: new (app: Application) => Controller,\n middleware: HttpMiddleware[] = []\n ) {\n path = path.replace(/\\//g, '/')\n\n const name = afterLast(path, '/')\n const basePath = `/${path}`.replace(/\\/+/g, '/')\n\n const controller = new Controller(this.app)\n\n this.addRoute('get', basePath, controller.index.bind(controller), `${name}.index`, middleware)\n this.addRoute('post', basePath, controller.store.bind(controller), `${name}.store`, middleware)\n this.addRoute('get', `${basePath}/:id`, controller.show.bind(controller), `${name}.show`, middleware)\n this.addRoute('put', `${basePath}/:id`, controller.update.bind(controller), `${name}.update`, middleware)\n this.addRoute('patch', `${basePath}/:id`, controller.update.bind(controller), `${name}.update`, middleware)\n this.addRoute('delete', `${basePath}/:id`, controller.destroy.bind(controller), `${name}.destroy`, middleware)\n }\n\n /**\n * Named route URL generator\n * \n * @param name \n * @param params \n * @returns \n */\n route (name: string, params: Record<string, string> = {}): string | undefined {\n const found = this.routes.find(r => r.name === name)\n if (!found) return undefined\n\n let url = found.path\n for (const [key, value] of Object.entries(params)) {\n url = url.replace(`:${key}`, value)\n }\n return url\n }\n\n /**\n * Grouping\n * \n * @param options \n * @param callback \n */\n group (options: { prefix?: string; middleware?: EventHandler[] }, callback: () => void) {\n const prevPrefix = this.groupPrefix\n const prevMiddleware = [...this.groupMiddleware]\n\n this.groupPrefix += options.prefix || ''\n this.groupMiddleware.push(...(options.middleware || []))\n\n callback()\n\n /**\n * Restore state after group\n */\n this.groupPrefix = prevPrefix\n this.groupMiddleware = prevMiddleware\n }\n\n middleware (path: string, handler: Middleware, opts?: MiddlewareOptions) {\n this.h3App.use(path, handler, opts)\n }\n}\n","import { readFile, stat } from \"node:fs/promises\";\n\nimport { ServiceProvider } from '@h3ravel/core'\nimport { before } from \"@h3ravel/support\";\nimport { join } from \"node:path\";\nimport { serveStatic } from 'h3'\nimport { statSync } from \"node:fs\";\n\n/**\n * Handles public assets loading\n * \n * Auto-Registered\n */\nexport class AssetsServiceProvider extends ServiceProvider {\n register () {\n const app = this.app.make('router')\n const config = this.app.make('config')\n const fsconfig = config.get('filesystem')\n const publicPath = this.app.getPath('public')\n\n app.middleware(`/${fsconfig.public_mask}/**`, (event) => {\n return serveStatic(event, {\n indexNames: [\"/index.html\"],\n getContents: (id) => {\n const newId = id.replace(`/${fsconfig.public_mask}/`, '')\n return readFile(join(before(publicPath, newId), newId))\n },\n getMeta: async (id) => {\n const newId = id.replace(`/${fsconfig.public_mask}/`, '')\n const stats = await stat(join(before(publicPath, newId), newId)).catch(() => { });\n if (stats?.isFile()) {\n return {\n size: stats.size,\n mtime: stats.mtimeMs,\n };\n }\n },\n });\n })\n\n this.app.singleton('asset', () => {\n return (key: string, def = '') => {\n try {\n statSync(join(before(publicPath, key), key))\n } catch {\n key = def\n }\n\n return join(fsconfig.public_mask, key)\n }\n })\n }\n}\n","import { Router } from '../Router'\nimport { ServiceProvider } from '@h3ravel/core'\nimport path from 'node:path'\nimport { readdir } from 'node:fs/promises'\n\n/**\n * Handles routing registration\n * \n * Load route files (web.ts, api.ts).\n * Map controllers to routes.\n * Register route-related middleware.\n * \n * Auto-Registered\n */\nexport class RouteServiceProvider extends ServiceProvider {\n register () {\n this.app.singleton('router', () => {\n const h3App = this.app.make('http.app')\n return new Router(h3App, this.app)\n })\n }\n\n /**\n * Load routes from src/routes\n */\n async boot () {\n try {\n const routePath = this.app.getPath('routes')\n\n const files = await readdir(routePath);\n\n for (let i = 0; i < files.length; i++) {\n const routesModule = await import(path.join(routePath, files[i]))\n\n if (typeof routesModule.default === 'function') {\n const router = this.app.make('router')\n routesModule.default(router)\n }\n }\n } catch (e) {\n console.warn('No web routes found or failed to load:', e)\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAeO,IAAMA,SAAN,MAAMA;EAdb,OAcaA;;;;;EACDC,SAA4B,CAAA;EAC5BC,cAAc;EACdC,kBAAkC,CAAA;EAE1C,YAAoBC,OAAmBC,KAAkB;SAArCD,QAAAA;SAAmBC,MAAAA;EAAoB;;;;;;;;EASnDC,eAAgBC,SAAuBC,aAA+B,CAAA,GAAI;AAC9E,WAAO,OAAOC,UAAAA;AACV,YAAMC,SAAS,IAAIC,OAAOH,UAAAA;AAC1B,aAAOE,OAAOE,OAAOH,OAAO,CAACI,QAAQC,QAAQC,QAAQR,QAAQM,GAAAA,CAAAA,CAAAA;IACjE;EACJ;;;;;;;;;;EAWQG,SACJC,QACAC,OACAX,SACAY,MACAX,aAA+B,CAAA,GACjC;AACE,UAAMY,WAAW,GAAG,KAAKlB,WAAW,GAAGgB,KAAAA,GAAOG,QAAQ,QAAQ,GAAA;AAC9D,SAAKpB,OAAOqB,KAAK;MAAEL;MAAQC,MAAME;MAAUD;MAAMZ;IAAQ,CAAA;AACzD,SAAKH,MAAMa,MAAAA,EAAiBG,UAAU,KAAKd,eAAeC,SAASC,UAAAA,CAAAA;EACvE;EAEQe,2BACJhB,SACAiB,YACY;AACZ,QAAI,OAAOjB,YAAY,cAAeA,QAAgBkB,qBAAqBC,YAAY;AACnF,aAAO,CAACb,QAAAA;AACJ,cAAMc,aAAa,IAAKpB,QAA+C,KAAKF,GAAG;AAC/E,cAAMuB,SAAUJ,cAAc;AAE9B,YAAI,OAAOG,WAAWC,MA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AACJ;;;AClDA,OAAOG,UAAU;AACjB,SAASC,eAAe;AAWjB,IAAMC,uBAAN,cAAmCC,gBAAAA;EAd1C,OAc0CA;;;EACtCC,WAAY;AACR,SAAKC,IAAIC,UAAU,UAAU,MAAA;AACzB,YAAMC,QAAQ,KAAKF,IAAIG,KAAK,UAAA;AAC5B,aAAO,IAAIC,OAAOF,OAAO,KAAKF,GAAG;IACrC,CAAA;EACJ;;;;EAKA,MAAMK,OAAQ;AACV,QAAI;AACA,YAAMC,YAAY,KAAKN,IAAIO,QAAQ,QAAA;AAEnC,YAAMC,QAAQ,MAAMC,QAAQH,SAAAA;AAE5B,eAASI,IAAI,GAAGA,IAAIF,MAAMG,QAAQD,KAAK;AACnC,cAAME,eAAe,MAAM,OAAOC,KAAKC,KAAKR,WAAWE,MAAME,CAAAA,CAAE;AAE/D,YAAI,OAAOE,aAAaG,YAAY,YAAY;AAC5C,gBAAMC,SAAS,KAAKhB,IAAIG,KAAK,QAAA;AAC7BS,uBAAaG,QAAQC,MAAAA;QACzB;MACJ;IACJ,SAASC,GAAG;AACRC,cAAQC,KAAK,0CAA0CF,CAAAA;IAC3D;EACJ;AACJ;","names":["Router","routes","groupPrefix","groupMiddleware","h3App","app","resolveHandler","handler","middleware","event","kernel","Kernel","handle","ctx","Promise","resolve","addRoute","method","path","name","fullPath","replace","push","resolveControllerOrHandler","methodName","prototype","Controller","controller","action","Error","get","post","put","delete","apiResource","afterLast","basePath","index","bind","store","show","update","destroy","route","params","found","find","r","undefined","url","key","value","Object","entries","group","options","callback","prevPrefix","prevMiddleware","prefix","opts","use","readFile","stat","join","serveStatic","statSync","AssetsServiceProvider","ServiceProvider","register","app","make","config","fsconfig","get","publicPath","getPath","middleware","public_mask","event","serveStatic","indexNames","getContents","id","newId","replace","readFile","join","before","getMeta","stats","stat","catch","isFile","size","mtime","mtimeMs","singleton","key","def","statSync","path","readdir","RouteServiceProvider","ServiceProvider","register","app","singleton","h3App","make","Router","boot","routePath","getPath","files","readdir","i","length","routesModule","path","join","default","router","e","console","warn"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ApiResource,
|
|
3
|
+
HttpServiceProvider,
|
|
4
|
+
JsonResource,
|
|
5
|
+
LogRequests,
|
|
6
|
+
Middleware,
|
|
7
|
+
Request,
|
|
8
|
+
Response
|
|
9
|
+
} from "./chunk-UZGBH6AC.js";
|
|
10
|
+
export {
|
|
11
|
+
ApiResource,
|
|
12
|
+
HttpServiceProvider,
|
|
13
|
+
JsonResource,
|
|
14
|
+
LogRequests,
|
|
15
|
+
Middleware,
|
|
16
|
+
Request,
|
|
17
|
+
Response
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=src-HATPJSC4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|