@h3ravel/shared 0.3.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 +18 -0
- package/LICENSE +21 -0
- package/dist/index.cjs +19 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +248 -0
- package/dist/index.d.ts +248 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/package.json +23 -0
- package/src/Contracts/IApplication.ts +56 -0
- package/src/Contracts/IHttp.ts +139 -0
- package/src/Contracts/IRequest.ts +42 -0
- package/src/Contracts/IResponse.ts +60 -0
- package/src/Contracts/IServiceProvider.ts +13 -0
- package/src/index.ts +9 -0
- package/tsconfig.json +16 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# @h3ravel/shared
|
|
2
|
+
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 3ff97bf: refactor: add a shared package to be extended by others to avoid cyclic dependency issues.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [3ff97bf]
|
|
12
|
+
- @h3ravel/support@0.3.0
|
|
13
|
+
|
|
14
|
+
## 0.2.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- aea734f: Fix all known bugs and improved interdependecy between packages.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 h3ravel
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/index.ts
|
|
17
|
+
var src_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(src_exports);
|
|
19
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from './Contracts/IApplication';\nexport * from './Contracts/IHttp';\nexport * from './Contracts/IRequest';\nexport * from './Contracts/IResponse';\nexport * from './Contracts/IServiceProvider';\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;;","names":[]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { H3Event, Middleware, MiddlewareOptions } from 'h3';
|
|
2
|
+
import { DotNestedKeys, DotNestedValue } from '@h3ravel/support';
|
|
3
|
+
|
|
4
|
+
interface IServiceProvider {
|
|
5
|
+
/**
|
|
6
|
+
* Register bindings to the container.
|
|
7
|
+
* Runs before boot().
|
|
8
|
+
*/
|
|
9
|
+
register(): void | Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Perform post-registration booting of services.
|
|
12
|
+
* Runs after all providers have been registered.
|
|
13
|
+
*/
|
|
14
|
+
boot?(): void | Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type IPathName = 'views' | 'routes' | 'assets' | 'base' | 'public' | 'storage' | 'config';
|
|
18
|
+
interface IApplication {
|
|
19
|
+
/**
|
|
20
|
+
* Registers configured service providers.
|
|
21
|
+
*/
|
|
22
|
+
registerConfiguredProviders(): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Registers an array of external service provider classes.
|
|
25
|
+
* @param providers - Array of service provider constructor functions.
|
|
26
|
+
*/
|
|
27
|
+
registerProviders(providers: Array<new (app: IApplication) => IServiceProvider>): void;
|
|
28
|
+
/**
|
|
29
|
+
* Registers a single service provider.
|
|
30
|
+
* @param provider - The service provider instance to register.
|
|
31
|
+
*/
|
|
32
|
+
register(provider: IServiceProvider): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Boots all registered providers.
|
|
35
|
+
*/
|
|
36
|
+
boot(): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Gets the base path of the application.
|
|
39
|
+
* @returns The base path as a string.
|
|
40
|
+
*/
|
|
41
|
+
getBasePath(): string;
|
|
42
|
+
/**
|
|
43
|
+
* Retrieves a path by name, optionally appending a sub-path.
|
|
44
|
+
* @param name - The name of the path property.
|
|
45
|
+
* @param pth - Optional sub-path to append.
|
|
46
|
+
* @returns The resolved path as a string.
|
|
47
|
+
*/
|
|
48
|
+
getPath(name: string, pth?: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* Sets a path for a given name.
|
|
51
|
+
* @param name - The name of the path property.
|
|
52
|
+
* @param path - The path to set.
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
setPath(name: IPathName, path: string): void;
|
|
56
|
+
/**
|
|
57
|
+
* Gets the version of the application or TypeScript.
|
|
58
|
+
* @param key - The key to retrieve ('app' or 'ts').
|
|
59
|
+
* @returns The version string or undefined.
|
|
60
|
+
*/
|
|
61
|
+
getVersion(key: 'app' | 'ts'): string | undefined;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Interface for the Request contract, defining methods for handling HTTP request data.
|
|
66
|
+
*/
|
|
67
|
+
interface IRequest {
|
|
68
|
+
/**
|
|
69
|
+
* Gets all input data (query parameters, route parameters, and body).
|
|
70
|
+
* @returns A promise resolving to an object containing all input data.
|
|
71
|
+
*/
|
|
72
|
+
all<T = Record<string, unknown>>(): Promise<T>;
|
|
73
|
+
/**
|
|
74
|
+
* Gets a single input field from query or body.
|
|
75
|
+
* @param key - The key of the input field.
|
|
76
|
+
* @param defaultValue - Optional default value if the key is not found.
|
|
77
|
+
* @returns A promise resolving to the value of the input field or the default value.
|
|
78
|
+
*/
|
|
79
|
+
input<T = unknown>(key: string, defaultValue?: T): Promise<T>;
|
|
80
|
+
/**
|
|
81
|
+
* Gets route parameters.
|
|
82
|
+
* @returns An object containing route parameters.
|
|
83
|
+
*/
|
|
84
|
+
params<T = Record<string, string>>(): T;
|
|
85
|
+
/**
|
|
86
|
+
* Gets query parameters.
|
|
87
|
+
* @returns An object containing query parameters.
|
|
88
|
+
*/
|
|
89
|
+
query<T = Record<string, string>>(): T;
|
|
90
|
+
/**
|
|
91
|
+
* Gets the underlying event object or a specific property of it.
|
|
92
|
+
* @param key - Optional key to access a nested property of the event.
|
|
93
|
+
* @returns The entire event object or the value of the specified property.
|
|
94
|
+
*/
|
|
95
|
+
getEvent(): H3Event;
|
|
96
|
+
getEvent<K extends DotNestedKeys<H3Event>>(key: K): DotNestedValue<H3Event, K>;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Interface for the Response contract, defining methods for handling HTTP responses.
|
|
101
|
+
*/
|
|
102
|
+
interface IResponse {
|
|
103
|
+
/**
|
|
104
|
+
* Sets the HTTP status code for the response.
|
|
105
|
+
* @param code - The HTTP status code.
|
|
106
|
+
* @returns The instance for method chaining.
|
|
107
|
+
*/
|
|
108
|
+
setStatusCode(code: number): this;
|
|
109
|
+
/**
|
|
110
|
+
* Sets a response header.
|
|
111
|
+
* @param name - The header name.
|
|
112
|
+
* @param value - The header value.
|
|
113
|
+
* @returns The instance for method chaining.
|
|
114
|
+
*/
|
|
115
|
+
setHeader(name: string, value: string): this;
|
|
116
|
+
/**
|
|
117
|
+
* Sends an HTML response.
|
|
118
|
+
* @param content - The HTML content to send.
|
|
119
|
+
* @returns The HTML content.
|
|
120
|
+
*/
|
|
121
|
+
html(content: string): string;
|
|
122
|
+
/**
|
|
123
|
+
* Sends a JSON response.
|
|
124
|
+
* @param data - The data to send as JSON.
|
|
125
|
+
* @returns The input data.
|
|
126
|
+
*/
|
|
127
|
+
json<T = unknown>(data: T): T;
|
|
128
|
+
/**
|
|
129
|
+
* Sends a plain text response.
|
|
130
|
+
* @param data - The text content to send.
|
|
131
|
+
* @returns The text content.
|
|
132
|
+
*/
|
|
133
|
+
text(data: string): string;
|
|
134
|
+
/**
|
|
135
|
+
* Redirects to another URL.
|
|
136
|
+
* @param url - The URL to redirect to.
|
|
137
|
+
* @param status - The HTTP status code for the redirect (default: 302).
|
|
138
|
+
* @returns The redirect URL.
|
|
139
|
+
*/
|
|
140
|
+
redirect(url: string, status?: number): string;
|
|
141
|
+
/**
|
|
142
|
+
* Gets the underlying event object or a specific property of it.
|
|
143
|
+
* @param key - Optional key to access a nested property of the event.
|
|
144
|
+
* @returns The entire event object or the value of the specified property.
|
|
145
|
+
*/
|
|
146
|
+
getEvent(): H3Event;
|
|
147
|
+
getEvent<K extends DotNestedKeys<H3Event>>(key: K): DotNestedValue<H3Event, K>;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Interface for the Router contract, defining methods for HTTP routing.
|
|
152
|
+
*/
|
|
153
|
+
interface IRouter {
|
|
154
|
+
/**
|
|
155
|
+
* Registers a GET route.
|
|
156
|
+
* @param path - The route path.
|
|
157
|
+
* @param handler - The handler function or controller class.
|
|
158
|
+
* @param methodName - Optional controller method name.
|
|
159
|
+
* @param name - Optional route name.
|
|
160
|
+
* @param middleware - Optional middleware array.
|
|
161
|
+
*/
|
|
162
|
+
get(path: string, handler: EventHandler | (new (...args: any[]) => IController), methodName?: string, name?: string, middleware?: IMiddleware[]): void;
|
|
163
|
+
/**
|
|
164
|
+
* Registers a POST route.
|
|
165
|
+
* @param path - The route path.
|
|
166
|
+
* @param handler - The handler function or controller class.
|
|
167
|
+
* @param methodName - Optional controller method name.
|
|
168
|
+
* @param name - Optional route name.
|
|
169
|
+
* @param middleware - Optional middleware array.
|
|
170
|
+
*/
|
|
171
|
+
post(path: string, handler: EventHandler | (new (...args: any[]) => IController), methodName?: string, name?: string, middleware?: IMiddleware[]): void;
|
|
172
|
+
/**
|
|
173
|
+
* Registers a PUT route.
|
|
174
|
+
* @param path - The route path.
|
|
175
|
+
* @param handler - The handler function or controller class.
|
|
176
|
+
* @param methodName - Optional controller method name.
|
|
177
|
+
* @param name - Optional route name.
|
|
178
|
+
* @param middleware - Optional middleware array.
|
|
179
|
+
*/
|
|
180
|
+
put(path: string, handler: EventHandler | (new (...args: any[]) => IController), methodName?: string, name?: string, middleware?: IMiddleware[]): void;
|
|
181
|
+
/**
|
|
182
|
+
* Registers a DELETE route.
|
|
183
|
+
* @param path - The route path.
|
|
184
|
+
* @param handler - The handler function or controller class.
|
|
185
|
+
* @param methodName - Optional controller method name.
|
|
186
|
+
* @param name - Optional route name.
|
|
187
|
+
* @param middleware - Optional middleware array.
|
|
188
|
+
*/
|
|
189
|
+
delete(path: string, handler: EventHandler | (new (...args: any[]) => IController), methodName?: string, name?: string, middleware?: IMiddleware[]): void;
|
|
190
|
+
/**
|
|
191
|
+
* Registers an API resource with standard CRUD routes.
|
|
192
|
+
* @param path - The base path for the resource.
|
|
193
|
+
* @param controller - The controller class handling the resource.
|
|
194
|
+
* @param middleware - Optional middleware array.
|
|
195
|
+
*/
|
|
196
|
+
apiResource(path: string, controller: new (app: IApplication) => IController, middleware?: IMiddleware[]): void;
|
|
197
|
+
/**
|
|
198
|
+
* Generates a URL for a named route.
|
|
199
|
+
* @param name - The name of the route.
|
|
200
|
+
* @param params - Optional parameters to replace in the route path.
|
|
201
|
+
* @returns The generated URL or undefined if the route is not found.
|
|
202
|
+
*/
|
|
203
|
+
route(name: string, params?: Record<string, string>): string | undefined;
|
|
204
|
+
/**
|
|
205
|
+
* Groups routes with shared prefix or middleware.
|
|
206
|
+
* @param options - Configuration for prefix or middleware.
|
|
207
|
+
* @param callback - Callback function defining grouped routes.
|
|
208
|
+
*/
|
|
209
|
+
group(options: {
|
|
210
|
+
prefix?: string;
|
|
211
|
+
middleware?: EventHandler[];
|
|
212
|
+
}, callback: () => void): void;
|
|
213
|
+
/**
|
|
214
|
+
* Registers middleware for a specific path.
|
|
215
|
+
* @param path - The path to apply the middleware.
|
|
216
|
+
* @param handler - The middleware handler.
|
|
217
|
+
* @param opts - Optional middleware options.
|
|
218
|
+
*/
|
|
219
|
+
middleware(path: string, handler: Middleware, opts?: MiddlewareOptions): void;
|
|
220
|
+
}
|
|
221
|
+
interface HttpContext {
|
|
222
|
+
request: IRequest;
|
|
223
|
+
response: IResponse;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Type for EventHandler, representing a function that handles an H3 event.
|
|
227
|
+
*/
|
|
228
|
+
type EventHandler = (ctx: HttpContext) => any;
|
|
229
|
+
/**
|
|
230
|
+
* Defines the contract for all controllers.
|
|
231
|
+
* Any controller implementing this must define these methods.
|
|
232
|
+
*/
|
|
233
|
+
interface IController {
|
|
234
|
+
show(ctx: HttpContext): any;
|
|
235
|
+
index(ctx: HttpContext): any;
|
|
236
|
+
store(ctx: HttpContext): any;
|
|
237
|
+
update(ctx: HttpContext): any;
|
|
238
|
+
destroy(ctx: HttpContext): any;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Defines the contract for all middlewares.
|
|
242
|
+
* Any middleware implementing this must define these methods.
|
|
243
|
+
*/
|
|
244
|
+
interface IMiddleware {
|
|
245
|
+
handle(context: HttpContext, next: () => Promise<any>): Promise<any>;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export type { EventHandler, HttpContext, IApplication, IController, IMiddleware, IPathName, IRequest, IResponse, IRouter, IServiceProvider };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { H3Event, Middleware, MiddlewareOptions } from 'h3';
|
|
2
|
+
import { DotNestedKeys, DotNestedValue } from '@h3ravel/support';
|
|
3
|
+
|
|
4
|
+
interface IServiceProvider {
|
|
5
|
+
/**
|
|
6
|
+
* Register bindings to the container.
|
|
7
|
+
* Runs before boot().
|
|
8
|
+
*/
|
|
9
|
+
register(): void | Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Perform post-registration booting of services.
|
|
12
|
+
* Runs after all providers have been registered.
|
|
13
|
+
*/
|
|
14
|
+
boot?(): void | Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type IPathName = 'views' | 'routes' | 'assets' | 'base' | 'public' | 'storage' | 'config';
|
|
18
|
+
interface IApplication {
|
|
19
|
+
/**
|
|
20
|
+
* Registers configured service providers.
|
|
21
|
+
*/
|
|
22
|
+
registerConfiguredProviders(): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Registers an array of external service provider classes.
|
|
25
|
+
* @param providers - Array of service provider constructor functions.
|
|
26
|
+
*/
|
|
27
|
+
registerProviders(providers: Array<new (app: IApplication) => IServiceProvider>): void;
|
|
28
|
+
/**
|
|
29
|
+
* Registers a single service provider.
|
|
30
|
+
* @param provider - The service provider instance to register.
|
|
31
|
+
*/
|
|
32
|
+
register(provider: IServiceProvider): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Boots all registered providers.
|
|
35
|
+
*/
|
|
36
|
+
boot(): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Gets the base path of the application.
|
|
39
|
+
* @returns The base path as a string.
|
|
40
|
+
*/
|
|
41
|
+
getBasePath(): string;
|
|
42
|
+
/**
|
|
43
|
+
* Retrieves a path by name, optionally appending a sub-path.
|
|
44
|
+
* @param name - The name of the path property.
|
|
45
|
+
* @param pth - Optional sub-path to append.
|
|
46
|
+
* @returns The resolved path as a string.
|
|
47
|
+
*/
|
|
48
|
+
getPath(name: string, pth?: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* Sets a path for a given name.
|
|
51
|
+
* @param name - The name of the path property.
|
|
52
|
+
* @param path - The path to set.
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
setPath(name: IPathName, path: string): void;
|
|
56
|
+
/**
|
|
57
|
+
* Gets the version of the application or TypeScript.
|
|
58
|
+
* @param key - The key to retrieve ('app' or 'ts').
|
|
59
|
+
* @returns The version string or undefined.
|
|
60
|
+
*/
|
|
61
|
+
getVersion(key: 'app' | 'ts'): string | undefined;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Interface for the Request contract, defining methods for handling HTTP request data.
|
|
66
|
+
*/
|
|
67
|
+
interface IRequest {
|
|
68
|
+
/**
|
|
69
|
+
* Gets all input data (query parameters, route parameters, and body).
|
|
70
|
+
* @returns A promise resolving to an object containing all input data.
|
|
71
|
+
*/
|
|
72
|
+
all<T = Record<string, unknown>>(): Promise<T>;
|
|
73
|
+
/**
|
|
74
|
+
* Gets a single input field from query or body.
|
|
75
|
+
* @param key - The key of the input field.
|
|
76
|
+
* @param defaultValue - Optional default value if the key is not found.
|
|
77
|
+
* @returns A promise resolving to the value of the input field or the default value.
|
|
78
|
+
*/
|
|
79
|
+
input<T = unknown>(key: string, defaultValue?: T): Promise<T>;
|
|
80
|
+
/**
|
|
81
|
+
* Gets route parameters.
|
|
82
|
+
* @returns An object containing route parameters.
|
|
83
|
+
*/
|
|
84
|
+
params<T = Record<string, string>>(): T;
|
|
85
|
+
/**
|
|
86
|
+
* Gets query parameters.
|
|
87
|
+
* @returns An object containing query parameters.
|
|
88
|
+
*/
|
|
89
|
+
query<T = Record<string, string>>(): T;
|
|
90
|
+
/**
|
|
91
|
+
* Gets the underlying event object or a specific property of it.
|
|
92
|
+
* @param key - Optional key to access a nested property of the event.
|
|
93
|
+
* @returns The entire event object or the value of the specified property.
|
|
94
|
+
*/
|
|
95
|
+
getEvent(): H3Event;
|
|
96
|
+
getEvent<K extends DotNestedKeys<H3Event>>(key: K): DotNestedValue<H3Event, K>;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Interface for the Response contract, defining methods for handling HTTP responses.
|
|
101
|
+
*/
|
|
102
|
+
interface IResponse {
|
|
103
|
+
/**
|
|
104
|
+
* Sets the HTTP status code for the response.
|
|
105
|
+
* @param code - The HTTP status code.
|
|
106
|
+
* @returns The instance for method chaining.
|
|
107
|
+
*/
|
|
108
|
+
setStatusCode(code: number): this;
|
|
109
|
+
/**
|
|
110
|
+
* Sets a response header.
|
|
111
|
+
* @param name - The header name.
|
|
112
|
+
* @param value - The header value.
|
|
113
|
+
* @returns The instance for method chaining.
|
|
114
|
+
*/
|
|
115
|
+
setHeader(name: string, value: string): this;
|
|
116
|
+
/**
|
|
117
|
+
* Sends an HTML response.
|
|
118
|
+
* @param content - The HTML content to send.
|
|
119
|
+
* @returns The HTML content.
|
|
120
|
+
*/
|
|
121
|
+
html(content: string): string;
|
|
122
|
+
/**
|
|
123
|
+
* Sends a JSON response.
|
|
124
|
+
* @param data - The data to send as JSON.
|
|
125
|
+
* @returns The input data.
|
|
126
|
+
*/
|
|
127
|
+
json<T = unknown>(data: T): T;
|
|
128
|
+
/**
|
|
129
|
+
* Sends a plain text response.
|
|
130
|
+
* @param data - The text content to send.
|
|
131
|
+
* @returns The text content.
|
|
132
|
+
*/
|
|
133
|
+
text(data: string): string;
|
|
134
|
+
/**
|
|
135
|
+
* Redirects to another URL.
|
|
136
|
+
* @param url - The URL to redirect to.
|
|
137
|
+
* @param status - The HTTP status code for the redirect (default: 302).
|
|
138
|
+
* @returns The redirect URL.
|
|
139
|
+
*/
|
|
140
|
+
redirect(url: string, status?: number): string;
|
|
141
|
+
/**
|
|
142
|
+
* Gets the underlying event object or a specific property of it.
|
|
143
|
+
* @param key - Optional key to access a nested property of the event.
|
|
144
|
+
* @returns The entire event object or the value of the specified property.
|
|
145
|
+
*/
|
|
146
|
+
getEvent(): H3Event;
|
|
147
|
+
getEvent<K extends DotNestedKeys<H3Event>>(key: K): DotNestedValue<H3Event, K>;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Interface for the Router contract, defining methods for HTTP routing.
|
|
152
|
+
*/
|
|
153
|
+
interface IRouter {
|
|
154
|
+
/**
|
|
155
|
+
* Registers a GET route.
|
|
156
|
+
* @param path - The route path.
|
|
157
|
+
* @param handler - The handler function or controller class.
|
|
158
|
+
* @param methodName - Optional controller method name.
|
|
159
|
+
* @param name - Optional route name.
|
|
160
|
+
* @param middleware - Optional middleware array.
|
|
161
|
+
*/
|
|
162
|
+
get(path: string, handler: EventHandler | (new (...args: any[]) => IController), methodName?: string, name?: string, middleware?: IMiddleware[]): void;
|
|
163
|
+
/**
|
|
164
|
+
* Registers a POST route.
|
|
165
|
+
* @param path - The route path.
|
|
166
|
+
* @param handler - The handler function or controller class.
|
|
167
|
+
* @param methodName - Optional controller method name.
|
|
168
|
+
* @param name - Optional route name.
|
|
169
|
+
* @param middleware - Optional middleware array.
|
|
170
|
+
*/
|
|
171
|
+
post(path: string, handler: EventHandler | (new (...args: any[]) => IController), methodName?: string, name?: string, middleware?: IMiddleware[]): void;
|
|
172
|
+
/**
|
|
173
|
+
* Registers a PUT route.
|
|
174
|
+
* @param path - The route path.
|
|
175
|
+
* @param handler - The handler function or controller class.
|
|
176
|
+
* @param methodName - Optional controller method name.
|
|
177
|
+
* @param name - Optional route name.
|
|
178
|
+
* @param middleware - Optional middleware array.
|
|
179
|
+
*/
|
|
180
|
+
put(path: string, handler: EventHandler | (new (...args: any[]) => IController), methodName?: string, name?: string, middleware?: IMiddleware[]): void;
|
|
181
|
+
/**
|
|
182
|
+
* Registers a DELETE route.
|
|
183
|
+
* @param path - The route path.
|
|
184
|
+
* @param handler - The handler function or controller class.
|
|
185
|
+
* @param methodName - Optional controller method name.
|
|
186
|
+
* @param name - Optional route name.
|
|
187
|
+
* @param middleware - Optional middleware array.
|
|
188
|
+
*/
|
|
189
|
+
delete(path: string, handler: EventHandler | (new (...args: any[]) => IController), methodName?: string, name?: string, middleware?: IMiddleware[]): void;
|
|
190
|
+
/**
|
|
191
|
+
* Registers an API resource with standard CRUD routes.
|
|
192
|
+
* @param path - The base path for the resource.
|
|
193
|
+
* @param controller - The controller class handling the resource.
|
|
194
|
+
* @param middleware - Optional middleware array.
|
|
195
|
+
*/
|
|
196
|
+
apiResource(path: string, controller: new (app: IApplication) => IController, middleware?: IMiddleware[]): void;
|
|
197
|
+
/**
|
|
198
|
+
* Generates a URL for a named route.
|
|
199
|
+
* @param name - The name of the route.
|
|
200
|
+
* @param params - Optional parameters to replace in the route path.
|
|
201
|
+
* @returns The generated URL or undefined if the route is not found.
|
|
202
|
+
*/
|
|
203
|
+
route(name: string, params?: Record<string, string>): string | undefined;
|
|
204
|
+
/**
|
|
205
|
+
* Groups routes with shared prefix or middleware.
|
|
206
|
+
* @param options - Configuration for prefix or middleware.
|
|
207
|
+
* @param callback - Callback function defining grouped routes.
|
|
208
|
+
*/
|
|
209
|
+
group(options: {
|
|
210
|
+
prefix?: string;
|
|
211
|
+
middleware?: EventHandler[];
|
|
212
|
+
}, callback: () => void): void;
|
|
213
|
+
/**
|
|
214
|
+
* Registers middleware for a specific path.
|
|
215
|
+
* @param path - The path to apply the middleware.
|
|
216
|
+
* @param handler - The middleware handler.
|
|
217
|
+
* @param opts - Optional middleware options.
|
|
218
|
+
*/
|
|
219
|
+
middleware(path: string, handler: Middleware, opts?: MiddlewareOptions): void;
|
|
220
|
+
}
|
|
221
|
+
interface HttpContext {
|
|
222
|
+
request: IRequest;
|
|
223
|
+
response: IResponse;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Type for EventHandler, representing a function that handles an H3 event.
|
|
227
|
+
*/
|
|
228
|
+
type EventHandler = (ctx: HttpContext) => any;
|
|
229
|
+
/**
|
|
230
|
+
* Defines the contract for all controllers.
|
|
231
|
+
* Any controller implementing this must define these methods.
|
|
232
|
+
*/
|
|
233
|
+
interface IController {
|
|
234
|
+
show(ctx: HttpContext): any;
|
|
235
|
+
index(ctx: HttpContext): any;
|
|
236
|
+
store(ctx: HttpContext): any;
|
|
237
|
+
update(ctx: HttpContext): any;
|
|
238
|
+
destroy(ctx: HttpContext): any;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Defines the contract for all middlewares.
|
|
242
|
+
* Any middleware implementing this must define these methods.
|
|
243
|
+
*/
|
|
244
|
+
interface IMiddleware {
|
|
245
|
+
handle(context: HttpContext, next: () => Promise<any>): Promise<any>;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export type { EventHandler, HttpContext, IApplication, IController, IMiddleware, IPathName, IRequest, IResponse, IRouter, IServiceProvider };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@h3ravel/shared",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Shared Utilities.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"h3": "^2.0.0-beta.1",
|
|
13
|
+
"@h3ravel/support": "0.3.0"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsup",
|
|
17
|
+
"barrel": "barrelsby --directory src --delete --singleQuotes",
|
|
18
|
+
"dev": "tsx watch src/index.ts",
|
|
19
|
+
"start": "node dist/index.js",
|
|
20
|
+
"lint": "eslint . --ext .ts",
|
|
21
|
+
"test": "vitest"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { IServiceProvider } from "./IServiceProvider";
|
|
2
|
+
|
|
3
|
+
export type IPathName = 'views' | 'routes' | 'assets' | 'base' | 'public' | 'storage' | 'config'
|
|
4
|
+
|
|
5
|
+
export interface IApplication {
|
|
6
|
+
/**
|
|
7
|
+
* Registers configured service providers.
|
|
8
|
+
*/
|
|
9
|
+
registerConfiguredProviders (): Promise<void>;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Registers an array of external service provider classes.
|
|
13
|
+
* @param providers - Array of service provider constructor functions.
|
|
14
|
+
*/
|
|
15
|
+
registerProviders (providers: Array<new (app: IApplication) => IServiceProvider>): void;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Registers a single service provider.
|
|
19
|
+
* @param provider - The service provider instance to register.
|
|
20
|
+
*/
|
|
21
|
+
register (provider: IServiceProvider): Promise<void>;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Boots all registered providers.
|
|
25
|
+
*/
|
|
26
|
+
boot (): Promise<void>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Gets the base path of the application.
|
|
30
|
+
* @returns The base path as a string.
|
|
31
|
+
*/
|
|
32
|
+
getBasePath (): string;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Retrieves a path by name, optionally appending a sub-path.
|
|
36
|
+
* @param name - The name of the path property.
|
|
37
|
+
* @param pth - Optional sub-path to append.
|
|
38
|
+
* @returns The resolved path as a string.
|
|
39
|
+
*/
|
|
40
|
+
getPath (name: string, pth?: string): string;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Sets a path for a given name.
|
|
44
|
+
* @param name - The name of the path property.
|
|
45
|
+
* @param path - The path to set.
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
setPath (name: IPathName, path: string): void;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Gets the version of the application or TypeScript.
|
|
52
|
+
* @param key - The key to retrieve ('app' or 'ts').
|
|
53
|
+
* @returns The version string or undefined.
|
|
54
|
+
*/
|
|
55
|
+
getVersion (key: 'app' | 'ts'): string | undefined;
|
|
56
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type { Middleware, MiddlewareOptions } from "h3";
|
|
2
|
+
|
|
3
|
+
import { IApplication } from "./IApplication";
|
|
4
|
+
import { IRequest } from "./IRequest";
|
|
5
|
+
import { IResponse } from "./IResponse";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Interface for the Router contract, defining methods for HTTP routing.
|
|
9
|
+
*/
|
|
10
|
+
export interface IRouter {
|
|
11
|
+
/**
|
|
12
|
+
* Registers a GET route.
|
|
13
|
+
* @param path - The route path.
|
|
14
|
+
* @param handler - The handler function or controller class.
|
|
15
|
+
* @param methodName - Optional controller method name.
|
|
16
|
+
* @param name - Optional route name.
|
|
17
|
+
* @param middleware - Optional middleware array.
|
|
18
|
+
*/
|
|
19
|
+
get (
|
|
20
|
+
path: string,
|
|
21
|
+
handler: EventHandler | (new (...args: any[]) => IController),
|
|
22
|
+
methodName?: string,
|
|
23
|
+
name?: string,
|
|
24
|
+
middleware?: IMiddleware[]
|
|
25
|
+
): void;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Registers a POST route.
|
|
29
|
+
* @param path - The route path.
|
|
30
|
+
* @param handler - The handler function or controller class.
|
|
31
|
+
* @param methodName - Optional controller method name.
|
|
32
|
+
* @param name - Optional route name.
|
|
33
|
+
* @param middleware - Optional middleware array.
|
|
34
|
+
*/
|
|
35
|
+
post (
|
|
36
|
+
path: string,
|
|
37
|
+
handler: EventHandler | (new (...args: any[]) => IController),
|
|
38
|
+
methodName?: string,
|
|
39
|
+
name?: string,
|
|
40
|
+
middleware?: IMiddleware[]
|
|
41
|
+
): void;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Registers a PUT route.
|
|
45
|
+
* @param path - The route path.
|
|
46
|
+
* @param handler - The handler function or controller class.
|
|
47
|
+
* @param methodName - Optional controller method name.
|
|
48
|
+
* @param name - Optional route name.
|
|
49
|
+
* @param middleware - Optional middleware array.
|
|
50
|
+
*/
|
|
51
|
+
put (
|
|
52
|
+
path: string,
|
|
53
|
+
handler: EventHandler | (new (...args: any[]) => IController),
|
|
54
|
+
methodName?: string,
|
|
55
|
+
name?: string,
|
|
56
|
+
middleware?: IMiddleware[]
|
|
57
|
+
): void;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Registers a DELETE route.
|
|
61
|
+
* @param path - The route path.
|
|
62
|
+
* @param handler - The handler function or controller class.
|
|
63
|
+
* @param methodName - Optional controller method name.
|
|
64
|
+
* @param name - Optional route name.
|
|
65
|
+
* @param middleware - Optional middleware array.
|
|
66
|
+
*/
|
|
67
|
+
delete (
|
|
68
|
+
path: string,
|
|
69
|
+
handler: EventHandler | (new (...args: any[]) => IController),
|
|
70
|
+
methodName?: string,
|
|
71
|
+
name?: string,
|
|
72
|
+
middleware?: IMiddleware[]
|
|
73
|
+
): void;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Registers an API resource with standard CRUD routes.
|
|
77
|
+
* @param path - The base path for the resource.
|
|
78
|
+
* @param controller - The controller class handling the resource.
|
|
79
|
+
* @param middleware - Optional middleware array.
|
|
80
|
+
*/
|
|
81
|
+
apiResource (
|
|
82
|
+
path: string,
|
|
83
|
+
controller: new (app: IApplication) => IController,
|
|
84
|
+
middleware?: IMiddleware[]
|
|
85
|
+
): void;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Generates a URL for a named route.
|
|
89
|
+
* @param name - The name of the route.
|
|
90
|
+
* @param params - Optional parameters to replace in the route path.
|
|
91
|
+
* @returns The generated URL or undefined if the route is not found.
|
|
92
|
+
*/
|
|
93
|
+
route (name: string, params?: Record<string, string>): string | undefined;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Groups routes with shared prefix or middleware.
|
|
97
|
+
* @param options - Configuration for prefix or middleware.
|
|
98
|
+
* @param callback - Callback function defining grouped routes.
|
|
99
|
+
*/
|
|
100
|
+
group (options: { prefix?: string; middleware?: EventHandler[] }, callback: () => void): void;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Registers middleware for a specific path.
|
|
104
|
+
* @param path - The path to apply the middleware.
|
|
105
|
+
* @param handler - The middleware handler.
|
|
106
|
+
* @param opts - Optional middleware options.
|
|
107
|
+
*/
|
|
108
|
+
middleware (path: string, handler: Middleware, opts?: MiddlewareOptions): void;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface HttpContext {
|
|
112
|
+
request: IRequest
|
|
113
|
+
response: IResponse
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Type for EventHandler, representing a function that handles an H3 event.
|
|
118
|
+
*/
|
|
119
|
+
export type EventHandler = (ctx: HttpContext) => any
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Defines the contract for all controllers.
|
|
123
|
+
* Any controller implementing this must define these methods.
|
|
124
|
+
*/
|
|
125
|
+
export interface IController {
|
|
126
|
+
show (ctx: HttpContext): any
|
|
127
|
+
index (ctx: HttpContext): any
|
|
128
|
+
store (ctx: HttpContext): any
|
|
129
|
+
update (ctx: HttpContext): any
|
|
130
|
+
destroy (ctx: HttpContext): any
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Defines the contract for all middlewares.
|
|
135
|
+
* Any middleware implementing this must define these methods.
|
|
136
|
+
*/
|
|
137
|
+
export interface IMiddleware {
|
|
138
|
+
handle (context: HttpContext, next: () => Promise<any>): Promise<any>
|
|
139
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { DotNestedKeys, DotNestedValue } from '@h3ravel/support'
|
|
2
|
+
|
|
3
|
+
import type { H3Event } from "h3";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Interface for the Request contract, defining methods for handling HTTP request data.
|
|
7
|
+
*/
|
|
8
|
+
export interface IRequest {
|
|
9
|
+
/**
|
|
10
|
+
* Gets all input data (query parameters, route parameters, and body).
|
|
11
|
+
* @returns A promise resolving to an object containing all input data.
|
|
12
|
+
*/
|
|
13
|
+
all<T = Record<string, unknown>> (): Promise<T>;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Gets a single input field from query or body.
|
|
17
|
+
* @param key - The key of the input field.
|
|
18
|
+
* @param defaultValue - Optional default value if the key is not found.
|
|
19
|
+
* @returns A promise resolving to the value of the input field or the default value.
|
|
20
|
+
*/
|
|
21
|
+
input<T = unknown> (key: string, defaultValue?: T): Promise<T>;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Gets route parameters.
|
|
25
|
+
* @returns An object containing route parameters.
|
|
26
|
+
*/
|
|
27
|
+
params<T = Record<string, string>> (): T;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Gets query parameters.
|
|
31
|
+
* @returns An object containing query parameters.
|
|
32
|
+
*/
|
|
33
|
+
query<T = Record<string, string>> (): T;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Gets the underlying event object or a specific property of it.
|
|
37
|
+
* @param key - Optional key to access a nested property of the event.
|
|
38
|
+
* @returns The entire event object or the value of the specified property.
|
|
39
|
+
*/
|
|
40
|
+
getEvent (): H3Event;
|
|
41
|
+
getEvent<K extends DotNestedKeys<H3Event>> (key: K): DotNestedValue<H3Event, K>;
|
|
42
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { DotNestedKeys, DotNestedValue } from '@h3ravel/support'
|
|
2
|
+
|
|
3
|
+
import type { H3Event } from "h3";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Interface for the Response contract, defining methods for handling HTTP responses.
|
|
7
|
+
*/
|
|
8
|
+
export interface IResponse {
|
|
9
|
+
/**
|
|
10
|
+
* Sets the HTTP status code for the response.
|
|
11
|
+
* @param code - The HTTP status code.
|
|
12
|
+
* @returns The instance for method chaining.
|
|
13
|
+
*/
|
|
14
|
+
setStatusCode (code: number): this;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Sets a response header.
|
|
18
|
+
* @param name - The header name.
|
|
19
|
+
* @param value - The header value.
|
|
20
|
+
* @returns The instance for method chaining.
|
|
21
|
+
*/
|
|
22
|
+
setHeader (name: string, value: string): this;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Sends an HTML response.
|
|
26
|
+
* @param content - The HTML content to send.
|
|
27
|
+
* @returns The HTML content.
|
|
28
|
+
*/
|
|
29
|
+
html (content: string): string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Sends a JSON response.
|
|
33
|
+
* @param data - The data to send as JSON.
|
|
34
|
+
* @returns The input data.
|
|
35
|
+
*/
|
|
36
|
+
json<T = unknown> (data: T): T;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Sends a plain text response.
|
|
40
|
+
* @param data - The text content to send.
|
|
41
|
+
* @returns The text content.
|
|
42
|
+
*/
|
|
43
|
+
text (data: string): string;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Redirects to another URL.
|
|
47
|
+
* @param url - The URL to redirect to.
|
|
48
|
+
* @param status - The HTTP status code for the redirect (default: 302).
|
|
49
|
+
* @returns The redirect URL.
|
|
50
|
+
*/
|
|
51
|
+
redirect (url: string, status?: number): string;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Gets the underlying event object or a specific property of it.
|
|
55
|
+
* @param key - Optional key to access a nested property of the event.
|
|
56
|
+
* @returns The entire event object or the value of the specified property.
|
|
57
|
+
*/
|
|
58
|
+
getEvent (): H3Event;
|
|
59
|
+
getEvent<K extends DotNestedKeys<H3Event>> (key: K): DotNestedValue<H3Event, K>;
|
|
60
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface IServiceProvider {
|
|
2
|
+
/**
|
|
3
|
+
* Register bindings to the container.
|
|
4
|
+
* Runs before boot().
|
|
5
|
+
*/
|
|
6
|
+
register (): void | Promise<void>
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Perform post-registration booting of services.
|
|
10
|
+
* Runs after all providers have been registered.
|
|
11
|
+
*/
|
|
12
|
+
boot?(): void | Promise<void>
|
|
13
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Automatically generated by barrelsby.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export * from './Contracts/IApplication';
|
|
6
|
+
export * from './Contracts/IHttp';
|
|
7
|
+
export * from './Contracts/IRequest';
|
|
8
|
+
export * from './Contracts/IResponse';
|
|
9
|
+
export * from './Contracts/IServiceProvider';
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"experimentalDecorators": true,
|
|
4
|
+
"emitDecoratorMetadata": true,
|
|
5
|
+
"target": "esnext",
|
|
6
|
+
"module": "preserve",
|
|
7
|
+
"moduleResolution": "Node",
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"strict": true,
|
|
10
|
+
"allowJs": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"resolveJsonModule": true
|
|
13
|
+
// "target": "ES2022",
|
|
14
|
+
// "module": "ESNext",
|
|
15
|
+
}
|
|
16
|
+
}
|