@vercube/core 0.0.3 → 0.0.4
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/index.d.mts +1193 -0
- package/dist/index.mjs +175 -174
- package/package.json +8 -23
- package/dist/Common/App.d.ts +0 -65
- package/dist/Common/Container.d.ts +0 -8
- package/dist/Common/CreateApp.d.ts +0 -8
- package/dist/Config/Config.d.ts +0 -7
- package/dist/Config/DefaultConfig.d.ts +0 -6
- package/dist/Config/Loader.d.ts +0 -7
- package/dist/Decorators/Hooks/Listen.d.ts +0 -9
- package/dist/Decorators/Http/Body.d.ts +0 -15
- package/dist/Decorators/Http/Connect.d.ts +0 -10
- package/dist/Decorators/Http/Controller.d.ts +0 -10
- package/dist/Decorators/Http/Delete.d.ts +0 -10
- package/dist/Decorators/Http/Get.d.ts +0 -10
- package/dist/Decorators/Http/Head.d.ts +0 -10
- package/dist/Decorators/Http/Header.d.ts +0 -11
- package/dist/Decorators/Http/Headers.d.ts +0 -9
- package/dist/Decorators/Http/Middleware.d.ts +0 -27
- package/dist/Decorators/Http/MultipartFormData.d.ts +0 -15
- package/dist/Decorators/Http/Options.d.ts +0 -10
- package/dist/Decorators/Http/Param.d.ts +0 -12
- package/dist/Decorators/Http/Patch.d.ts +0 -10
- package/dist/Decorators/Http/Post.d.ts +0 -10
- package/dist/Decorators/Http/Put.d.ts +0 -10
- package/dist/Decorators/Http/QueryParam.d.ts +0 -16
- package/dist/Decorators/Http/QueryParams.d.ts +0 -15
- package/dist/Decorators/Http/Redirect.d.ts +0 -13
- package/dist/Decorators/Http/Request.d.ts +0 -9
- package/dist/Decorators/Http/Response.d.ts +0 -9
- package/dist/Decorators/Http/Session.d.ts +0 -9
- package/dist/Decorators/Http/SetHeader.d.ts +0 -7
- package/dist/Decorators/Http/Status.d.ts +0 -11
- package/dist/Decorators/Http/Trace.d.ts +0 -10
- package/dist/Errors/Http/BadRequestError.d.ts +0 -17
- package/dist/Errors/Http/ForbiddenError.d.ts +0 -17
- package/dist/Errors/Http/InternalServerError.d.ts +0 -17
- package/dist/Errors/Http/MethodNotAllowedError.d.ts +0 -17
- package/dist/Errors/Http/NotAcceptableError.d.ts +0 -17
- package/dist/Errors/Http/NotFoundError.d.ts +0 -17
- package/dist/Errors/Http/UnauthorizedError.d.ts +0 -17
- package/dist/Errors/HttpError.d.ts +0 -17
- package/dist/Hooks/Router/RouterAfterInitHook.d.ts +0 -1
- package/dist/Hooks/Router/RouterBeforeInitHook.d.ts +0 -1
- package/dist/Middleware/ValidationMiddleware.d.ts +0 -23
- package/dist/Resolvers/Body.d.ts +0 -22
- package/dist/Resolvers/Headers.d.ts +0 -14
- package/dist/Resolvers/Query.d.ts +0 -14
- package/dist/Resolvers/RouterParam.d.ts +0 -13
- package/dist/Services/Config/RuntimeConfig.d.ts +0 -22
- package/dist/Services/ErrorHandler/DefaultErrorHandlerProvider.d.ts +0 -16
- package/dist/Services/ErrorHandler/ErrorHandlerProvider.d.ts +0 -16
- package/dist/Services/Hooks/HooksService.d.ts +0 -76
- package/dist/Services/HttpServer/HttpServer.d.ts +0 -57
- package/dist/Services/Metadata/MetadataResolver.d.ts +0 -42
- package/dist/Services/Middleware/BaseMiddleware.d.ts +0 -31
- package/dist/Services/Middleware/GlobalMiddlewareRegistry.d.ts +0 -31
- package/dist/Services/Plugins/BasePlugin.d.ts +0 -16
- package/dist/Services/Plugins/PluginsRegistry.d.ts +0 -26
- package/dist/Services/Router/RequestHandler.d.ts +0 -63
- package/dist/Services/Router/Router.d.ts +0 -40
- package/dist/Services/Router/StaticRequestHandler.d.ts +0 -38
- package/dist/Services/Validation/StandardSchemaValidationProvider.d.ts +0 -17
- package/dist/Services/Validation/ValidationProvider.d.ts +0 -17
- package/dist/Types/CommonTypes.d.ts +0 -7
- package/dist/Types/ConfigTypes.d.ts +0 -124
- package/dist/Types/HooksTypes.d.ts +0 -17
- package/dist/Types/HttpTypes.d.ts +0 -63
- package/dist/Types/MetadataTypes.d.ts +0 -56
- package/dist/Types/RouterTypes.d.ts +0 -37
- package/dist/Types/ValidationTypes.d.ts +0 -6
- package/dist/Utils/InternalUtils.d.ts +0 -1
- package/dist/Utils/Mine.d.ts +0 -3
- package/dist/Utils/Utils.d.ts +0 -22
- package/dist/index.cjs +0 -2704
- package/dist/index.d.ts +0 -52
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1193 @@
|
|
|
1
|
+
import { Container } from "@vercube/di";
|
|
2
|
+
import { FastResponse } from "srvx";
|
|
3
|
+
import { LoggerTypes } from "@vercube/logger";
|
|
4
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
5
|
+
|
|
6
|
+
//#region src/Services/Plugins/BasePlugin.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Represents a Plugin.
|
|
9
|
+
*/
|
|
10
|
+
declare class BasePlugin<T = unknown> {
|
|
11
|
+
/**
|
|
12
|
+
* The name of the plugin.
|
|
13
|
+
*/
|
|
14
|
+
name: string;
|
|
15
|
+
/**
|
|
16
|
+
* Uses the plugin with the given app.
|
|
17
|
+
* @param {App} app - The application instance.
|
|
18
|
+
* @returns {void | Promise<void>} - A void or a promise that resolves to void.
|
|
19
|
+
*/
|
|
20
|
+
use(app: App, options?: T): void | Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/Types/ConfigTypes.d.ts
|
|
24
|
+
/**
|
|
25
|
+
* Namespace containing configuration type definitions for the Vercube framework.
|
|
26
|
+
*/
|
|
27
|
+
declare namespace ConfigTypes {
|
|
28
|
+
/**
|
|
29
|
+
* Runtime configuration interface that can be modified during application execution.
|
|
30
|
+
*/
|
|
31
|
+
interface RuntimeConfig {
|
|
32
|
+
/**
|
|
33
|
+
* Session configuration options.
|
|
34
|
+
*/
|
|
35
|
+
session?: {
|
|
36
|
+
/**
|
|
37
|
+
* The secret used to sign the session ID cookie.
|
|
38
|
+
*/
|
|
39
|
+
secret?: string;
|
|
40
|
+
/**
|
|
41
|
+
* The name of the session ID cookie.
|
|
42
|
+
*/
|
|
43
|
+
name?: string;
|
|
44
|
+
/**
|
|
45
|
+
* The duration of time for the session to be active.
|
|
46
|
+
*/
|
|
47
|
+
duration?: number;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Configuration options for experimental features.
|
|
52
|
+
* These options may change or be removed in future versions.
|
|
53
|
+
*/
|
|
54
|
+
interface ExperimentalOptions {}
|
|
55
|
+
/**
|
|
56
|
+
* Build configuration options for the application.
|
|
57
|
+
*/
|
|
58
|
+
interface BuildOptions {
|
|
59
|
+
/**
|
|
60
|
+
* The root directory for the application.
|
|
61
|
+
*/
|
|
62
|
+
root?: string;
|
|
63
|
+
/**
|
|
64
|
+
* The entry point file for the application build.
|
|
65
|
+
*/
|
|
66
|
+
entry?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Defines to pass to the build.
|
|
69
|
+
*/
|
|
70
|
+
define?: Record<string, string>;
|
|
71
|
+
/**
|
|
72
|
+
* Output configuration for build artifacts.
|
|
73
|
+
*/
|
|
74
|
+
output?: {
|
|
75
|
+
/**
|
|
76
|
+
* The main output directory for build artifacts.
|
|
77
|
+
*/
|
|
78
|
+
dir?: string;
|
|
79
|
+
/**
|
|
80
|
+
* The directory for public/client-side build artifacts.
|
|
81
|
+
*/
|
|
82
|
+
publicDir?: string;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* The bundler to use for the application build.
|
|
86
|
+
*/
|
|
87
|
+
bundler?: 'rolldown';
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Server configuration options for the application.
|
|
91
|
+
*/
|
|
92
|
+
interface ServerOptions {
|
|
93
|
+
/**
|
|
94
|
+
* The runtime environment for the application.
|
|
95
|
+
*/
|
|
96
|
+
runtime?: 'node' | 'bun' | 'deno';
|
|
97
|
+
/**
|
|
98
|
+
* The hostname to bind the server to.
|
|
99
|
+
*/
|
|
100
|
+
host?: string;
|
|
101
|
+
/**
|
|
102
|
+
* The port number to listen on.
|
|
103
|
+
*/
|
|
104
|
+
port?: number;
|
|
105
|
+
/**
|
|
106
|
+
* HTTPS configuration options.
|
|
107
|
+
*/
|
|
108
|
+
https?: false | {
|
|
109
|
+
/**
|
|
110
|
+
* Path to the SSL key file.
|
|
111
|
+
*/
|
|
112
|
+
key: string;
|
|
113
|
+
/**
|
|
114
|
+
* Path to the SSL certificate file.
|
|
115
|
+
*/
|
|
116
|
+
cert: string;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Static server options
|
|
120
|
+
*/
|
|
121
|
+
static?: {
|
|
122
|
+
dirs: string[];
|
|
123
|
+
maxAge?: number;
|
|
124
|
+
immutable?: boolean;
|
|
125
|
+
etag?: boolean;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Main configuration interface for the Vercube application.
|
|
130
|
+
*/
|
|
131
|
+
interface Config {
|
|
132
|
+
/**
|
|
133
|
+
* Flag indicating if the application is running in production mode.
|
|
134
|
+
*/
|
|
135
|
+
production?: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Flag indicating if the application is running in development mode.
|
|
138
|
+
*/
|
|
139
|
+
dev?: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* The logging level for the application.
|
|
142
|
+
*/
|
|
143
|
+
logLevel?: LoggerTypes.Level;
|
|
144
|
+
/**
|
|
145
|
+
* Server configuration options.
|
|
146
|
+
*/
|
|
147
|
+
server?: ServerOptions;
|
|
148
|
+
/**
|
|
149
|
+
* Runtime configuration for the application.
|
|
150
|
+
*/
|
|
151
|
+
runtime?: RuntimeConfig;
|
|
152
|
+
/**
|
|
153
|
+
* Experimental features configuration.
|
|
154
|
+
*/
|
|
155
|
+
experimental?: ExperimentalOptions;
|
|
156
|
+
/**
|
|
157
|
+
* Build configuration options.
|
|
158
|
+
* This property is only used when using vercube cli.
|
|
159
|
+
*/
|
|
160
|
+
build?: BuildOptions;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region src/Common/App.d.ts
|
|
165
|
+
/**
|
|
166
|
+
* Represents the main application class.
|
|
167
|
+
*/
|
|
168
|
+
declare class App {
|
|
169
|
+
private gRouter;
|
|
170
|
+
private gPluginsRegistry;
|
|
171
|
+
private gHttpServer;
|
|
172
|
+
private gStaticRequestHandler;
|
|
173
|
+
private gLogger;
|
|
174
|
+
/** Holds the initialization status of the application */
|
|
175
|
+
private fIsInitialized;
|
|
176
|
+
/** Holds the dependency injection container */
|
|
177
|
+
private fInternalContainer;
|
|
178
|
+
/** Hold app config */
|
|
179
|
+
private fConfig;
|
|
180
|
+
/**
|
|
181
|
+
* Gets the dependency injection container.
|
|
182
|
+
*
|
|
183
|
+
* @returns {Container} The dependency injection container.
|
|
184
|
+
*/
|
|
185
|
+
get container(): Container;
|
|
186
|
+
/**
|
|
187
|
+
* Sets the dependency injection container.
|
|
188
|
+
*
|
|
189
|
+
* @param {Container} container - The dependency injection container.
|
|
190
|
+
*/
|
|
191
|
+
set container(container: Container);
|
|
192
|
+
/**
|
|
193
|
+
* Initializes the application.
|
|
194
|
+
*
|
|
195
|
+
* @returns {Promise<void>} A promise that resolves when the application is initialized.
|
|
196
|
+
*/
|
|
197
|
+
init(cfg: ConfigTypes.Config): Promise<void>;
|
|
198
|
+
/**
|
|
199
|
+
* Registers a plugin.
|
|
200
|
+
*
|
|
201
|
+
* @param {typeof Plugin} plugin - The plugin to register.
|
|
202
|
+
* @param {unknown} options - The options to pass to the plugin.
|
|
203
|
+
*/
|
|
204
|
+
registerPlugin<T>(plugin: typeof BasePlugin<T>, options?: T): void;
|
|
205
|
+
/**
|
|
206
|
+
* Starts the application and begins listening for incoming requests.
|
|
207
|
+
*
|
|
208
|
+
* @returns {Promise<void>} A promise that resolves when the application starts listening.
|
|
209
|
+
* @throws {Error} If the application is already initialized.
|
|
210
|
+
*/
|
|
211
|
+
listen(): Promise<void>;
|
|
212
|
+
/**
|
|
213
|
+
* Handles an incoming HTTP request.
|
|
214
|
+
* This method is an adapter for HttpServer.handleRequest method.
|
|
215
|
+
*
|
|
216
|
+
* @param {Request} request - The incoming HTTP request
|
|
217
|
+
* @returns {Promise<Response>} The HTTP response
|
|
218
|
+
*/
|
|
219
|
+
fetch(request: Request): Promise<Response>;
|
|
220
|
+
/**
|
|
221
|
+
* Resolves and initializes the plugins for the application.
|
|
222
|
+
*
|
|
223
|
+
* @private
|
|
224
|
+
*/
|
|
225
|
+
private resolvePlugins;
|
|
226
|
+
}
|
|
227
|
+
//#endregion
|
|
228
|
+
//#region src/Common/CreateApp.d.ts
|
|
229
|
+
/**
|
|
230
|
+
* Creates and initializes an instance of the App.
|
|
231
|
+
*
|
|
232
|
+
* @returns {Promise<App>} A promise that resolves to an instance of the App.
|
|
233
|
+
*/
|
|
234
|
+
declare function createApp(cfg?: ConfigTypes.Config): Promise<App>;
|
|
235
|
+
//#endregion
|
|
236
|
+
//#region src/Config/Config.d.ts
|
|
237
|
+
/**
|
|
238
|
+
* Defines a configuration object for the application
|
|
239
|
+
* @param {ConfigTypes.Config} config - The configuration object to validate
|
|
240
|
+
* @returns {ConfigTypes.Config} The validated configuration object
|
|
241
|
+
*/
|
|
242
|
+
declare function defineConfig(config: ConfigTypes.Config): ConfigTypes.Config;
|
|
243
|
+
//#endregion
|
|
244
|
+
//#region src/Config/Loader.d.ts
|
|
245
|
+
/**
|
|
246
|
+
* Loads the configuration object for the application
|
|
247
|
+
* @param {ConfigTypes.Config} overrides - The configuration object to load
|
|
248
|
+
* @returns {ConfigTypes.Config} The loaded configuration object
|
|
249
|
+
*/
|
|
250
|
+
declare function loadVercubeConfig(overrides?: ConfigTypes.Config): Promise<ConfigTypes.Config>;
|
|
251
|
+
//#endregion
|
|
252
|
+
//#region src/Types/ValidationTypes.d.ts
|
|
253
|
+
declare namespace ValidationTypes {
|
|
254
|
+
type Schema = StandardSchemaV1;
|
|
255
|
+
type Result<T = any> = StandardSchemaV1.Result<T>;
|
|
256
|
+
type Input<T extends Schema = Schema> = StandardSchemaV1.InferInput<T>;
|
|
257
|
+
}
|
|
258
|
+
//#endregion
|
|
259
|
+
//#region src/Decorators/Http/Body.d.ts
|
|
260
|
+
interface BodyDecoratorOptions {
|
|
261
|
+
validationSchema?: ValidationTypes.Schema;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* @function Body
|
|
265
|
+
* @returns {Function} A decorator function that registers the BodyDecorator.
|
|
266
|
+
*
|
|
267
|
+
* This function creates and returns a decorator that can be used to annotate
|
|
268
|
+
* a parameter in a method to indicate that it should be populated with the
|
|
269
|
+
* body of an HTTP request. The decorator uses the BodyDecorator class to
|
|
270
|
+
* handle the metadata associated with the parameter.
|
|
271
|
+
*/
|
|
272
|
+
declare function Body(options?: BodyDecoratorOptions): Function;
|
|
273
|
+
//#endregion
|
|
274
|
+
//#region src/Decorators/Http/Connect.d.ts
|
|
275
|
+
/**
|
|
276
|
+
* A factory function for creating a ConnectDecorator.
|
|
277
|
+
*
|
|
278
|
+
* This function returns a decorator function that can be used to annotate
|
|
279
|
+
* a method with CONNECT route information.
|
|
280
|
+
*
|
|
281
|
+
* @param {string} path - The path for the CONNECT route.
|
|
282
|
+
* @return {Function} The decorator function.
|
|
283
|
+
*/
|
|
284
|
+
declare function Connect(path: string): Function;
|
|
285
|
+
//#endregion
|
|
286
|
+
//#region src/Decorators/Http/Controller.d.ts
|
|
287
|
+
/**
|
|
288
|
+
* A factory function for creating a Controller decorator.
|
|
289
|
+
*
|
|
290
|
+
* This function returns a decorator function that can be used to annotate
|
|
291
|
+
* a class with controller metadata, including the base path for the controller.
|
|
292
|
+
*
|
|
293
|
+
* @param {string} path - The base path for the controller.
|
|
294
|
+
* @return {Function} The decorator function.
|
|
295
|
+
*/
|
|
296
|
+
declare function Controller(path: string): Function;
|
|
297
|
+
//#endregion
|
|
298
|
+
//#region src/Decorators/Http/Delete.d.ts
|
|
299
|
+
/**
|
|
300
|
+
* A factory function for creating a DeleteDecorator.
|
|
301
|
+
*
|
|
302
|
+
* This function returns a decorator function that can be used to annotate
|
|
303
|
+
* a method with DELETE route information.
|
|
304
|
+
*
|
|
305
|
+
* @param {string} path - The path for the DELETE route.
|
|
306
|
+
* @return {Function} The decorator function.
|
|
307
|
+
*/
|
|
308
|
+
declare function Delete(path: string): Function;
|
|
309
|
+
//#endregion
|
|
310
|
+
//#region src/Decorators/Http/Get.d.ts
|
|
311
|
+
/**
|
|
312
|
+
* A decorator function for handling HTTP GET requests.
|
|
313
|
+
*
|
|
314
|
+
* This function creates an instance of the GetDecorator class and registers
|
|
315
|
+
* the GET route with the specified path.
|
|
316
|
+
*
|
|
317
|
+
* @param {string} path - The path for the GET route.
|
|
318
|
+
* @returns {Function} - The decorator function.
|
|
319
|
+
*/
|
|
320
|
+
declare function Get(path: string): Function;
|
|
321
|
+
//#endregion
|
|
322
|
+
//#region src/Decorators/Http/Head.d.ts
|
|
323
|
+
/**
|
|
324
|
+
* A factory function for creating a HeadDecorator.
|
|
325
|
+
*
|
|
326
|
+
* This function returns a decorator function that can be used to annotate
|
|
327
|
+
* a method with HEAD route information.
|
|
328
|
+
*
|
|
329
|
+
* @param {string} path - The path for the HEAD route.
|
|
330
|
+
* @return {Function} The decorator function.
|
|
331
|
+
*/
|
|
332
|
+
declare function Head(path: string): Function;
|
|
333
|
+
//#endregion
|
|
334
|
+
//#region src/Decorators/Http/Header.d.ts
|
|
335
|
+
/**
|
|
336
|
+
* A decorator function for handling HTTP header parameters.
|
|
337
|
+
*
|
|
338
|
+
* This function creates a HeaderDecorator with the specified name and registers it.
|
|
339
|
+
* It is used to annotate a parameter in a method to indicate that it should be
|
|
340
|
+
* populated with the value of a specific HTTP header.
|
|
341
|
+
*
|
|
342
|
+
* @param {string} name - The name of the HTTP header to bind to the parameter.
|
|
343
|
+
* @returns {Function} - A decorator function that registers the HeaderDecorator.
|
|
344
|
+
*/
|
|
345
|
+
declare function Header(name: string): Function;
|
|
346
|
+
//#endregion
|
|
347
|
+
//#region src/Decorators/Http/Headers.d.ts
|
|
348
|
+
/**
|
|
349
|
+
* A factory function for creating a HeadersDecorator.
|
|
350
|
+
*
|
|
351
|
+
* This function returns a decorator function that can be used to annotate
|
|
352
|
+
* a method parameter with headers information.
|
|
353
|
+
*
|
|
354
|
+
* @return {Function} The decorator function.
|
|
355
|
+
*/
|
|
356
|
+
declare function Headers(): Function;
|
|
357
|
+
//#endregion
|
|
358
|
+
//#region src/Decorators/Http/Options.d.ts
|
|
359
|
+
/**
|
|
360
|
+
* A factory function for creating an OptionsDecorator.
|
|
361
|
+
*
|
|
362
|
+
* This function returns a decorator function that can be used to annotate
|
|
363
|
+
* a method with OPTIONS route information.
|
|
364
|
+
*
|
|
365
|
+
* @param {string} path - The path for the OPTIONS route.
|
|
366
|
+
* @return {Function} The decorator function.
|
|
367
|
+
*/
|
|
368
|
+
declare function Options(path: string): Function;
|
|
369
|
+
//#endregion
|
|
370
|
+
//#region src/Decorators/Http/Param.d.ts
|
|
371
|
+
/**
|
|
372
|
+
* A factory function for creating a ParamDecorator.
|
|
373
|
+
*
|
|
374
|
+
* This function returns a decorator function that can be used to annotate
|
|
375
|
+
* a method parameter with parameter information.
|
|
376
|
+
*
|
|
377
|
+
* @param {string} name - The name of the parameter.
|
|
378
|
+
* @param {Object} [opts] - Optional settings for the parameter.
|
|
379
|
+
* @param {boolean} [opts.decode=false] - Whether to decode the parameter.
|
|
380
|
+
* @return {Function} The decorator function.
|
|
381
|
+
*/
|
|
382
|
+
declare function Param(name: string): Function;
|
|
383
|
+
//#endregion
|
|
384
|
+
//#region src/Decorators/Http/Patch.d.ts
|
|
385
|
+
/**
|
|
386
|
+
* A factory function for creating a PatchDecorator.
|
|
387
|
+
*
|
|
388
|
+
* This function returns a decorator function that can be used to annotate
|
|
389
|
+
* a method with PATCH route information.
|
|
390
|
+
*
|
|
391
|
+
* @param {string} path - The path for the PATCH route.
|
|
392
|
+
* @return {Function} The decorator function.
|
|
393
|
+
*/
|
|
394
|
+
declare function Patch(path: string): Function;
|
|
395
|
+
//#endregion
|
|
396
|
+
//#region src/Decorators/Http/Post.d.ts
|
|
397
|
+
/**
|
|
398
|
+
* A factory function for creating a PostDecorator.
|
|
399
|
+
*
|
|
400
|
+
* This function returns a decorator function that can be used to annotate
|
|
401
|
+
* a method with POST route information.
|
|
402
|
+
*
|
|
403
|
+
* @param {string} path - The path for the POST route.
|
|
404
|
+
* @return {Function} The decorator function.
|
|
405
|
+
*/
|
|
406
|
+
declare function Post(path: string): Function;
|
|
407
|
+
//#endregion
|
|
408
|
+
//#region src/Decorators/Http/Put.d.ts
|
|
409
|
+
/**
|
|
410
|
+
* A factory function for creating a PutDecorator.
|
|
411
|
+
*
|
|
412
|
+
* This function returns a decorator function that can be used to annotate
|
|
413
|
+
* a method with PUT route information.
|
|
414
|
+
*
|
|
415
|
+
* @param {string} path - The path for the PUT route.
|
|
416
|
+
* @return {Function} The decorator function.
|
|
417
|
+
*/
|
|
418
|
+
declare function Put(path: string): Function;
|
|
419
|
+
//#endregion
|
|
420
|
+
//#region src/Decorators/Http/QueryParam.d.ts
|
|
421
|
+
interface QueryParamDecoratorOptions {
|
|
422
|
+
name: string;
|
|
423
|
+
validationSchema?: ValidationTypes.Schema;
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* A factory function for creating a QueryDecorator.
|
|
427
|
+
*
|
|
428
|
+
* This function returns a decorator function that can be used to annotate
|
|
429
|
+
* a method parameter with query parameter information.
|
|
430
|
+
*
|
|
431
|
+
* @param {QueryParamDecoratorOptions} options - The options for the decorator.
|
|
432
|
+
* @return {Function} The decorator function.
|
|
433
|
+
*/
|
|
434
|
+
declare function QueryParam(options: QueryParamDecoratorOptions): Function;
|
|
435
|
+
//#endregion
|
|
436
|
+
//#region src/Decorators/Http/QueryParams.d.ts
|
|
437
|
+
interface QueryParamsDecoratorOptions {
|
|
438
|
+
validationSchema?: ValidationTypes.Schema;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* A factory function for creating a QueryParamsDecorator.
|
|
442
|
+
*
|
|
443
|
+
* This function returns a decorator function that can be used to annotate
|
|
444
|
+
* a method parameter with query parameter information.
|
|
445
|
+
*
|
|
446
|
+
* @param {QueryParamsDecoratorOptions} options - The options for the decorator.
|
|
447
|
+
* @return {Function} The decorator function.
|
|
448
|
+
*/
|
|
449
|
+
declare function QueryParams(options?: QueryParamsDecoratorOptions): Function;
|
|
450
|
+
//#endregion
|
|
451
|
+
//#region src/Decorators/Http/Request.d.ts
|
|
452
|
+
/**
|
|
453
|
+
* A factory function for creating a RequestDecorator.
|
|
454
|
+
*
|
|
455
|
+
* This function returns a decorator function that can be used to annotate
|
|
456
|
+
* a method parameter with request information.
|
|
457
|
+
*
|
|
458
|
+
* @return {Function} The decorator function.
|
|
459
|
+
*/
|
|
460
|
+
declare function Request$1(): Function;
|
|
461
|
+
//#endregion
|
|
462
|
+
//#region src/Decorators/Http/Response.d.ts
|
|
463
|
+
/**
|
|
464
|
+
* A factory function for creating a ResponseDecorator.
|
|
465
|
+
*
|
|
466
|
+
* This function returns a decorator function that can be used to annotate
|
|
467
|
+
* a method parameter with response information.
|
|
468
|
+
*
|
|
469
|
+
* @return {Function} The decorator function.
|
|
470
|
+
*/
|
|
471
|
+
declare function Response$1(): Function;
|
|
472
|
+
//#endregion
|
|
473
|
+
//#region src/Decorators/Http/Trace.d.ts
|
|
474
|
+
/**
|
|
475
|
+
* A factory function for creating a TraceDecorator.
|
|
476
|
+
*
|
|
477
|
+
* This function returns a decorator function that can be used to annotate
|
|
478
|
+
* a method with TRACE route information.
|
|
479
|
+
*
|
|
480
|
+
* @param {string} path - The path for the TRACE route.
|
|
481
|
+
* @return {Function} The decorator function.
|
|
482
|
+
*/
|
|
483
|
+
declare function Trace(path: string): Function;
|
|
484
|
+
//#endregion
|
|
485
|
+
//#region src/Decorators/Http/SetHeader.d.ts
|
|
486
|
+
/**
|
|
487
|
+
* Creates a SetHeader decorator.
|
|
488
|
+
* @param {string} key - The header key.
|
|
489
|
+
* @param {string} value - The header value.
|
|
490
|
+
* @returns {Function} The decorator function.
|
|
491
|
+
*/
|
|
492
|
+
declare function SetHeader(key: string, value: string): Function;
|
|
493
|
+
//#endregion
|
|
494
|
+
//#region src/Types/HttpTypes.d.ts
|
|
495
|
+
declare enum HTTPStatus {
|
|
496
|
+
CONTINUE = 100,
|
|
497
|
+
SWITCHING_PROTOCOLS = 101,
|
|
498
|
+
PROCESSING = 102,
|
|
499
|
+
OK = 200,
|
|
500
|
+
CREATED = 201,
|
|
501
|
+
ACCEPTED = 202,
|
|
502
|
+
NON_AUTHORITATIVE_INFORMATION = 203,
|
|
503
|
+
NO_CONTENT = 204,
|
|
504
|
+
RESET_CONTENT = 205,
|
|
505
|
+
PARTIAL_CONTENT = 206,
|
|
506
|
+
MULTI_STATUS = 207,
|
|
507
|
+
ALREADY_REPORTED = 208,
|
|
508
|
+
IM_USED = 226,
|
|
509
|
+
MULTIPLE_CHOICES = 300,
|
|
510
|
+
MOVED_PERMANENTLY = 301,
|
|
511
|
+
FOUND = 302,
|
|
512
|
+
SEE_OTHER = 303,
|
|
513
|
+
NOT_MODIFIED = 304,
|
|
514
|
+
USE_PROXY = 305,
|
|
515
|
+
TEMPORARY_REDIRECT = 307,
|
|
516
|
+
PERMANENT_REDIRECT = 308,
|
|
517
|
+
BAD_REQUEST = 400,
|
|
518
|
+
UNAUTHORIZED = 401,
|
|
519
|
+
PAYMENT_REQUIRED = 402,
|
|
520
|
+
FORBIDDEN = 403,
|
|
521
|
+
NOT_FOUND = 404,
|
|
522
|
+
METHOD_NOT_ALLOWED = 405,
|
|
523
|
+
NOT_ACCEPTABLE = 406,
|
|
524
|
+
PROXY_AUTHENTICATION_REQUIRED = 407,
|
|
525
|
+
REQUEST_TIMEOUT = 408,
|
|
526
|
+
CONFLICT = 409,
|
|
527
|
+
GONE = 410,
|
|
528
|
+
LENGTH_REQUIRED = 411,
|
|
529
|
+
PRECONDITION_FAILED = 412,
|
|
530
|
+
PAYLOAD_TOO_LARGE = 413,
|
|
531
|
+
URI_TOO_LONG = 414,
|
|
532
|
+
UNSUPPORTED_MEDIA_TYPE = 415,
|
|
533
|
+
RANGE_NOT_SATISFIABLE = 416,
|
|
534
|
+
EXPECTATION_FAILED = 417,
|
|
535
|
+
I_AM_A_TEAPOT = 418,
|
|
536
|
+
// Easter egg from RFC 2324
|
|
537
|
+
MISDIRECTED_REQUEST = 421,
|
|
538
|
+
UNPROCESSABLE_ENTITY = 422,
|
|
539
|
+
LOCKED = 423,
|
|
540
|
+
FAILED_DEPENDENCY = 424,
|
|
541
|
+
TOO_EARLY = 425,
|
|
542
|
+
UPGRADE_REQUIRED = 426,
|
|
543
|
+
PRECONDITION_REQUIRED = 428,
|
|
544
|
+
TOO_MANY_REQUESTS = 429,
|
|
545
|
+
REQUEST_HEADER_FIELDS_TOO_LARGE = 431,
|
|
546
|
+
UNAVAILABLE_FOR_LEGAL_REASONS = 451,
|
|
547
|
+
INTERNAL_SERVER_ERROR = 500,
|
|
548
|
+
NOT_IMPLEMENTED = 501,
|
|
549
|
+
BAD_GATEWAY = 502,
|
|
550
|
+
SERVICE_UNAVAILABLE = 503,
|
|
551
|
+
GATEWAY_TIMEOUT = 504,
|
|
552
|
+
HTTP_VERSION_NOT_SUPPORTED = 505,
|
|
553
|
+
VARIANT_ALSO_NEGOTIATES = 506,
|
|
554
|
+
INSUFFICIENT_STORAGE = 507,
|
|
555
|
+
LOOP_DETECTED = 508,
|
|
556
|
+
NOT_EXTENDED = 510,
|
|
557
|
+
NETWORK_AUTHENTICATION_REQUIRED = 511,
|
|
558
|
+
}
|
|
559
|
+
//#endregion
|
|
560
|
+
//#region src/Decorators/Http/Status.d.ts
|
|
561
|
+
/**
|
|
562
|
+
* Creates a Status decorator.
|
|
563
|
+
* @param {number} code - The status value.
|
|
564
|
+
* @returns {Function} The decorator function.
|
|
565
|
+
*/
|
|
566
|
+
declare function Status(code: HTTPStatus): Function;
|
|
567
|
+
//#endregion
|
|
568
|
+
//#region src/Decorators/Http/Redirect.d.ts
|
|
569
|
+
/**
|
|
570
|
+
* Creates a Redirect decorator.
|
|
571
|
+
* @param {string} location - The location header value.
|
|
572
|
+
* @param {number} [code=301] - The status code.
|
|
573
|
+
* @returns {Function} The decorator function.
|
|
574
|
+
*/
|
|
575
|
+
declare function Redirect(location: string, code?: HTTPStatus): Function;
|
|
576
|
+
//#endregion
|
|
577
|
+
//#region src/Types/RouterTypes.d.ts
|
|
578
|
+
declare namespace RouterTypes {
|
|
579
|
+
interface Route {
|
|
580
|
+
path: string;
|
|
581
|
+
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' | 'HEAD' | 'CONNECT' | 'TRACE';
|
|
582
|
+
handler: RouterHandler;
|
|
583
|
+
}
|
|
584
|
+
interface RouteFind {
|
|
585
|
+
path: string;
|
|
586
|
+
method: string;
|
|
587
|
+
}
|
|
588
|
+
interface MiddlewareDefinition {
|
|
589
|
+
middleware: BaseMiddleware<unknown, unknown>;
|
|
590
|
+
target: string;
|
|
591
|
+
priority?: number;
|
|
592
|
+
args?: unknown;
|
|
593
|
+
}
|
|
594
|
+
interface RouterHandler {
|
|
595
|
+
instance: any;
|
|
596
|
+
propertyName: string;
|
|
597
|
+
args: MetadataTypes.Arg[];
|
|
598
|
+
middlewares: {
|
|
599
|
+
beforeMiddlewares: MiddlewareDefinition[];
|
|
600
|
+
afterMiddlewares: MiddlewareDefinition[];
|
|
601
|
+
};
|
|
602
|
+
actions: MetadataTypes.Action[];
|
|
603
|
+
}
|
|
604
|
+
interface RouteMatched<T = unknown> {
|
|
605
|
+
data: T;
|
|
606
|
+
params?: Record<string, string>;
|
|
607
|
+
}
|
|
608
|
+
type RouterEvent = RouterTypes.RouteMatched<RouterTypes.RouterHandler> & {
|
|
609
|
+
request: Request;
|
|
610
|
+
response: Response;
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
//#endregion
|
|
614
|
+
//#region src/Types/MetadataTypes.d.ts
|
|
615
|
+
declare namespace MetadataTypes {
|
|
616
|
+
interface Metadata {
|
|
617
|
+
__metadata: Ctx;
|
|
618
|
+
}
|
|
619
|
+
interface Ctx {
|
|
620
|
+
__controller: {
|
|
621
|
+
path: string;
|
|
622
|
+
};
|
|
623
|
+
__middlewares: Middleware[];
|
|
624
|
+
__methods: Record<string, Method>;
|
|
625
|
+
}
|
|
626
|
+
interface Method {
|
|
627
|
+
req: Request | null;
|
|
628
|
+
res: Response | null;
|
|
629
|
+
url: string | null;
|
|
630
|
+
args: Arg[];
|
|
631
|
+
actions: Action[];
|
|
632
|
+
}
|
|
633
|
+
interface ResolvedData {
|
|
634
|
+
req: Request | null;
|
|
635
|
+
res: Response | null;
|
|
636
|
+
url: string | null;
|
|
637
|
+
args: Arg[];
|
|
638
|
+
actions: Action[];
|
|
639
|
+
middlewares: Middleware[];
|
|
640
|
+
}
|
|
641
|
+
interface Arg {
|
|
642
|
+
idx: number;
|
|
643
|
+
type: string;
|
|
644
|
+
data?: Record<string, any>;
|
|
645
|
+
resolver?: (event: RouterTypes.RouterEvent) => Promise<unknown>;
|
|
646
|
+
resolved?: unknown;
|
|
647
|
+
validate?: boolean;
|
|
648
|
+
validationSchema?: ValidationTypes.Schema;
|
|
649
|
+
}
|
|
650
|
+
interface Action {
|
|
651
|
+
handler: (req: Request, res: Response) => void | Response | ResponseInit;
|
|
652
|
+
}
|
|
653
|
+
interface Middleware<T = unknown, U = unknown> {
|
|
654
|
+
target: string;
|
|
655
|
+
priority?: number;
|
|
656
|
+
middleware: typeof BaseMiddleware<T, U>;
|
|
657
|
+
args?: unknown;
|
|
658
|
+
}
|
|
659
|
+
interface ResolveUrlParams {
|
|
660
|
+
instance: any;
|
|
661
|
+
path: string;
|
|
662
|
+
propertyName: string;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
//#endregion
|
|
666
|
+
//#region src/Types/CommonTypes.d.ts
|
|
667
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
668
|
+
interface MiddlewareOptions<T = any> {
|
|
669
|
+
middlewareArgs?: T;
|
|
670
|
+
methodArgs?: MetadataTypes.Arg[];
|
|
671
|
+
}
|
|
672
|
+
//#endregion
|
|
673
|
+
//#region src/Services/Middleware/BaseMiddleware.d.ts
|
|
674
|
+
/**
|
|
675
|
+
* BaseMiddleware class that serves as a base for all middleware implementations.
|
|
676
|
+
*/
|
|
677
|
+
declare class BaseMiddleware<T = any, U = any> {
|
|
678
|
+
/**
|
|
679
|
+
* Middleware function that processes the HTTP event.
|
|
680
|
+
* This method should be overridden by subclasses to implement specific middleware logic.
|
|
681
|
+
* WARNING: This method cannot return a value, it will be ignored.
|
|
682
|
+
* Middleware can only modify the event object or throw an HttpError like BadRequestError, ForbiddenError, etc.
|
|
683
|
+
*
|
|
684
|
+
* @param {Request} request - The HTTP Request to process
|
|
685
|
+
* @param {T[]} args - Additional arguments for the middleware.
|
|
686
|
+
* @returns {void | Promise<void>} - A void or a promise that resolves when the processing is complete.
|
|
687
|
+
*/
|
|
688
|
+
onRequest?(request: Request, response: Response, args: MiddlewareOptions<T>): MaybePromise<void | Response>;
|
|
689
|
+
/**
|
|
690
|
+
* Middleware function that processes the response.
|
|
691
|
+
* This method should be overridden by subclasses to implement specific middleware logic.
|
|
692
|
+
* WARNING: This method cannot return a value, it will be ignored.
|
|
693
|
+
* Middleware can only modify the event object or throw an HttpError like BadRequestError, ForbiddenError, etc.
|
|
694
|
+
*
|
|
695
|
+
* @param {Request} request - The HTTP Request to process
|
|
696
|
+
* @param {Response} response - The HTTP Response to process
|
|
697
|
+
* @returns {void | Promise<void>} - A void or a promise that resolves when the processing is complete.
|
|
698
|
+
*/
|
|
699
|
+
onResponse?(request: Request, response: Response, payload: U): MaybePromise<void | Response>;
|
|
700
|
+
}
|
|
701
|
+
//#endregion
|
|
702
|
+
//#region src/Decorators/Http/Middleware.d.ts
|
|
703
|
+
interface MiddlewareDecoratorParams extends Omit<MetadataTypes.Middleware, 'middleware'> {}
|
|
704
|
+
/**
|
|
705
|
+
* Decorator that applies middleware to a class or method
|
|
706
|
+
* @param middleware - The middleware class to apply
|
|
707
|
+
* @param opts - Optional configuration parameters
|
|
708
|
+
* @param opts.type - The type of middleware ('before' or 'after')
|
|
709
|
+
* @param opts.priority - Priority order for middleware execution (default: 999)
|
|
710
|
+
* @returns A decorator function that can be applied to classes or methods
|
|
711
|
+
*
|
|
712
|
+
* @example
|
|
713
|
+
* ```typescript
|
|
714
|
+
* @Middleware(AuthMiddleware)
|
|
715
|
+
* class UserController {
|
|
716
|
+
* // ...
|
|
717
|
+
* }
|
|
718
|
+
*
|
|
719
|
+
* // Or on a specific method:
|
|
720
|
+
* @Middleware(ValidationMiddleware, { type: 'before', priority: 1 })
|
|
721
|
+
* public async createUser() {
|
|
722
|
+
* // ...
|
|
723
|
+
* }
|
|
724
|
+
* ```
|
|
725
|
+
*/
|
|
726
|
+
declare function Middleware$1(middleware: typeof BaseMiddleware, opts?: MiddlewareDecoratorParams): Function;
|
|
727
|
+
//#endregion
|
|
728
|
+
//#region src/Decorators/Http/MultipartFormData.d.ts
|
|
729
|
+
/**
|
|
730
|
+
* Decorator function that marks a parameter as multipart/form-data request body.
|
|
731
|
+
* This decorator will automatically parse incoming multipart form data
|
|
732
|
+
*
|
|
733
|
+
* @decorator
|
|
734
|
+
* @returns {Function} A decorator function that can be applied to method parameters
|
|
735
|
+
*
|
|
736
|
+
* @example
|
|
737
|
+
* class UserController {
|
|
738
|
+
* uploadFile(@MultipartFormData() formData: MyData) {
|
|
739
|
+
* // Handle multipart form data
|
|
740
|
+
* }
|
|
741
|
+
* }
|
|
742
|
+
*/
|
|
743
|
+
declare function MultipartFormData(): Function;
|
|
744
|
+
//#endregion
|
|
745
|
+
//#region src/Decorators/Http/Session.d.ts
|
|
746
|
+
/**
|
|
747
|
+
* A factory function for creating a SessionDecorator.
|
|
748
|
+
*
|
|
749
|
+
* This function returns a decorator function that can be used to annotate
|
|
750
|
+
* a method parameter with session information.
|
|
751
|
+
*
|
|
752
|
+
* @return {Function} The decorator function.
|
|
753
|
+
*/
|
|
754
|
+
declare function Session(): Function;
|
|
755
|
+
//#endregion
|
|
756
|
+
//#region src/Types/HooksTypes.d.ts
|
|
757
|
+
declare namespace HooksTypes {
|
|
758
|
+
interface HookType<T> {
|
|
759
|
+
new (): T;
|
|
760
|
+
}
|
|
761
|
+
type HookData<T> = { [P in keyof T]: T[P] };
|
|
762
|
+
interface HookCallback<T> {
|
|
763
|
+
(data: T): void | Promise<void>;
|
|
764
|
+
}
|
|
765
|
+
interface HookHandler<T> {
|
|
766
|
+
id: number;
|
|
767
|
+
callback: HookCallback<T>;
|
|
768
|
+
}
|
|
769
|
+
interface HookID {
|
|
770
|
+
readonly __id: number;
|
|
771
|
+
readonly __type: HookType<any>;
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
//#endregion
|
|
775
|
+
//#region src/Decorators/Hooks/Listen.d.ts
|
|
776
|
+
/**
|
|
777
|
+
* This decorator stores metadata about hook listeners. It can be later used along with function
|
|
778
|
+
* applyEventListeners() to automatically register all listeners.
|
|
779
|
+
*
|
|
780
|
+
* @param hookType hook to listen for
|
|
781
|
+
* @return decorator function
|
|
782
|
+
*/
|
|
783
|
+
declare function Listen(hookType: HooksTypes.HookType<unknown>): Function;
|
|
784
|
+
//#endregion
|
|
785
|
+
//#region src/Services/Hooks/HooksService.d.ts
|
|
786
|
+
/**
|
|
787
|
+
* This class is responsible for managing events.
|
|
788
|
+
*/
|
|
789
|
+
declare class HooksService {
|
|
790
|
+
private fLastId;
|
|
791
|
+
private fHandlers;
|
|
792
|
+
/**
|
|
793
|
+
* Registers listener for event of particular type. Everytime event is called, the listener
|
|
794
|
+
* will be executed.
|
|
795
|
+
*
|
|
796
|
+
* @param type type of event, simple class
|
|
797
|
+
* @param callback callback fired when event is triggered
|
|
798
|
+
* @returns unique ID for event listener, can be used to disable this listener
|
|
799
|
+
*/
|
|
800
|
+
on<T>(type: HooksTypes.HookType<T>, callback: HooksTypes.HookCallback<T>): HooksTypes.HookID;
|
|
801
|
+
/**
|
|
802
|
+
* Waits for single event execution and removes the listener immediately after.
|
|
803
|
+
*
|
|
804
|
+
* @example
|
|
805
|
+
* this.gCart.addItem(product);
|
|
806
|
+
* await this.gEvents.waitFor(CartUpdatedEvent);
|
|
807
|
+
* console.log('here cart updated event is already called');
|
|
808
|
+
*
|
|
809
|
+
* @param type type of event to wait for
|
|
810
|
+
* @param timeout timeout param in ms - if event is not thrown until this time, it'll reject. passing null disables the timeout
|
|
811
|
+
* @returns promise with event data that resolves when event is finally called
|
|
812
|
+
*/
|
|
813
|
+
waitFor<T>(type: HooksTypes.HookType<T>, timeout?: number | null): Promise<T>;
|
|
814
|
+
/**
|
|
815
|
+
* Removes listener from particular event.
|
|
816
|
+
* @param eventId eventId returned from .on() method.
|
|
817
|
+
* @throws Error if event was not registered
|
|
818
|
+
*/
|
|
819
|
+
off<T>(eventId: HooksTypes.HookID): void;
|
|
820
|
+
/**
|
|
821
|
+
* Triggers event, calling all listener callbacks. Will return Promise of number,
|
|
822
|
+
* that is resolved when all asynchronous listeners are called.
|
|
823
|
+
* @param type type of trigger, simple class
|
|
824
|
+
* @param data data which will be passed to listeners, based on event class
|
|
825
|
+
* @return number of listeners that were notified
|
|
826
|
+
*/
|
|
827
|
+
trigger<T>(type: HooksTypes.HookType<T>, data?: HooksTypes.HookData<T>): Promise<number>;
|
|
828
|
+
/**
|
|
829
|
+
* Converts plain object to it's class equivalent.
|
|
830
|
+
* It's NOT class-transformer, it performs basic key assigment.
|
|
831
|
+
*
|
|
832
|
+
* @param ClassConstructor event constructor
|
|
833
|
+
* @param data event data to be mapped to constructor
|
|
834
|
+
* @return class type of event
|
|
835
|
+
*/
|
|
836
|
+
private objectToClass;
|
|
837
|
+
}
|
|
838
|
+
//#endregion
|
|
839
|
+
//#region src/Services/Middleware/GlobalMiddlewareRegistry.d.ts
|
|
840
|
+
interface GlobalMiddlewareParams<T> extends Omit<MetadataTypes.Middleware<T>, 'middleware'> {}
|
|
841
|
+
/**
|
|
842
|
+
* Manages global middleware registration and retrieval
|
|
843
|
+
*
|
|
844
|
+
* This class provides functionality to register and retrieve global middleware
|
|
845
|
+
* configurations. It allows for adding middleware with specific options and
|
|
846
|
+
* retrieving them in a standardized format.
|
|
847
|
+
*/
|
|
848
|
+
declare class GlobalMiddlewareRegistry {
|
|
849
|
+
private fMiddlewares;
|
|
850
|
+
/**
|
|
851
|
+
* Retrieves all registered global middleware configurations
|
|
852
|
+
*
|
|
853
|
+
* @returns {MetadataTypes.Middleware[]} An array of middleware configurations
|
|
854
|
+
*/
|
|
855
|
+
get middlewares(): MetadataTypes.Middleware[];
|
|
856
|
+
/**
|
|
857
|
+
* Registers a global middleware configuration
|
|
858
|
+
*
|
|
859
|
+
* @param {typeof BaseMiddleware<T, U>} middleware - The middleware class to register
|
|
860
|
+
* @param {GlobalMiddlewareParams<T>} opts - The middleware options
|
|
861
|
+
* @returns {void}
|
|
862
|
+
*/
|
|
863
|
+
registerGlobalMiddleware<T = unknown, U = unknown>(middleware: typeof BaseMiddleware<T, U>, opts?: GlobalMiddlewareParams<T>): void;
|
|
864
|
+
}
|
|
865
|
+
//#endregion
|
|
866
|
+
//#region src/Services/HttpServer/HttpServer.d.ts
|
|
867
|
+
/**
|
|
868
|
+
* HTTP server implementation for handling incoming web requests
|
|
869
|
+
*
|
|
870
|
+
* This class is responsible for:
|
|
871
|
+
* - Initializing and managing the HTTP server
|
|
872
|
+
* - Routing incoming requests to appropriate handlers
|
|
873
|
+
* - Processing HTTP responses
|
|
874
|
+
*/
|
|
875
|
+
declare class HttpServer {
|
|
876
|
+
/**
|
|
877
|
+
* DI container for resolving dependencies
|
|
878
|
+
*/
|
|
879
|
+
private gContainer;
|
|
880
|
+
/**
|
|
881
|
+
* Router service for resolving routes
|
|
882
|
+
*/
|
|
883
|
+
private gRouter;
|
|
884
|
+
/**
|
|
885
|
+
* Handler for processing HTTP requests
|
|
886
|
+
*/
|
|
887
|
+
private gRequestHandler;
|
|
888
|
+
/**
|
|
889
|
+
* Static server for serving static files
|
|
890
|
+
*/
|
|
891
|
+
private gStaticRequestHandler;
|
|
892
|
+
/**
|
|
893
|
+
* Underlying server instance
|
|
894
|
+
* @private
|
|
895
|
+
*/
|
|
896
|
+
private fServer;
|
|
897
|
+
/**
|
|
898
|
+
* Initializes the HTTP server and starts listening for requests
|
|
899
|
+
*
|
|
900
|
+
* @returns {Promise<void>} A promise that resolves when the server is ready
|
|
901
|
+
*/
|
|
902
|
+
initialize(config: ConfigTypes.Config): Promise<void>;
|
|
903
|
+
/**
|
|
904
|
+
* Listens for incoming requests on the HTTP server
|
|
905
|
+
*
|
|
906
|
+
* @returns {Promise<void>} A promise that resolves when the server is ready to listen
|
|
907
|
+
*/
|
|
908
|
+
listen(): Promise<void>;
|
|
909
|
+
/**
|
|
910
|
+
* Processes an incoming HTTP request
|
|
911
|
+
*
|
|
912
|
+
* This method:
|
|
913
|
+
* 1. Resolves the route for the request
|
|
914
|
+
* 2. Returns a 404 response if no route is found
|
|
915
|
+
* 3. Delegates to the request handler for matched routes
|
|
916
|
+
*
|
|
917
|
+
* @param {Request} request - The incoming HTTP request
|
|
918
|
+
* @returns {Promise<Response>} The HTTP response
|
|
919
|
+
* @private
|
|
920
|
+
*/
|
|
921
|
+
handleRequest(request: Request): Promise<Response>;
|
|
922
|
+
}
|
|
923
|
+
//#endregion
|
|
924
|
+
//#region src/Services/Metadata/MetadataResolver.d.ts
|
|
925
|
+
/**
|
|
926
|
+
* Class responsible for resolving metadata for route handlers.
|
|
927
|
+
*/
|
|
928
|
+
declare class MetadataResolver {
|
|
929
|
+
/**
|
|
930
|
+
* Resolves the URL for a given instance and path.
|
|
931
|
+
*
|
|
932
|
+
* @param {MetadataTypes.ResolveUrlParams} params - The parameters for resolving the URL.
|
|
933
|
+
* @return {string} The resolved URL.
|
|
934
|
+
*/
|
|
935
|
+
resolveUrl(params: MetadataTypes.ResolveUrlParams): string;
|
|
936
|
+
resolveMethod(ctx: MetadataTypes.Metadata, propertyName: string): MetadataTypes.Method;
|
|
937
|
+
/**
|
|
938
|
+
* Resolves arguments for a given event.
|
|
939
|
+
*
|
|
940
|
+
* @param {MetadataTypes.Arg[]} args - The arguments to resolve.
|
|
941
|
+
* @param {RouterTypes.RouterEvent} event - The event to resolve arguments for.
|
|
942
|
+
* @return {unknown[]} The resolved arguments.
|
|
943
|
+
* @public
|
|
944
|
+
*/
|
|
945
|
+
resolveArgs(args: MetadataTypes.Arg[], event: RouterTypes.RouterEvent): Promise<MetadataTypes.Arg[]>;
|
|
946
|
+
/**
|
|
947
|
+
* Resolves an argument for a given event.
|
|
948
|
+
*
|
|
949
|
+
* @param {MetadataTypes.Arg} arg - The argument to resolve.
|
|
950
|
+
*
|
|
951
|
+
* @return {unknown} The resolved argument.
|
|
952
|
+
* @private
|
|
953
|
+
*/
|
|
954
|
+
private resolveArg;
|
|
955
|
+
/**
|
|
956
|
+
* Resolves middleware functions for a given context and property name.
|
|
957
|
+
*
|
|
958
|
+
* @param {MetadataTypes.Ctx} ctx - The metadata context object
|
|
959
|
+
* @param {string} propertyName - The name of the property to resolve middlewares for
|
|
960
|
+
* @returns {MetadataTypes.Middleware[]} Array of middleware functions that apply globally or to the specific property
|
|
961
|
+
* @public
|
|
962
|
+
*/
|
|
963
|
+
resolveMiddlewares(ctx: MetadataTypes.Metadata, propertyName: string): MetadataTypes.Middleware[];
|
|
964
|
+
}
|
|
965
|
+
//#endregion
|
|
966
|
+
//#region src/Services/ErrorHandler/ErrorHandlerProvider.d.ts
|
|
967
|
+
/**
|
|
968
|
+
* Abstract class representing an error handler provider
|
|
969
|
+
* Provides a common interface for different error handler implementations
|
|
970
|
+
*
|
|
971
|
+
* @abstract
|
|
972
|
+
* @class ErrorHandlerProvider
|
|
973
|
+
*/
|
|
974
|
+
declare abstract class ErrorHandlerProvider {
|
|
975
|
+
/**
|
|
976
|
+
* Handles an error that occurred during request processing
|
|
977
|
+
*
|
|
978
|
+
* @param error - The Error object containing error details
|
|
979
|
+
* @returns Promise<Response> | Response - The response to be sent to the client
|
|
980
|
+
*/
|
|
981
|
+
abstract handleError(error: Error): Promise<Response> | Response;
|
|
982
|
+
}
|
|
983
|
+
//#endregion
|
|
984
|
+
//#region src/Services/Router/Router.d.ts
|
|
985
|
+
/**
|
|
986
|
+
* Router service responsible for managing application routes
|
|
987
|
+
*
|
|
988
|
+
* This class provides functionality to initialize the router,
|
|
989
|
+
* register routes, and resolve incoming requests to their
|
|
990
|
+
* appropriate handlers.
|
|
991
|
+
*/
|
|
992
|
+
declare class Router {
|
|
993
|
+
/**
|
|
994
|
+
* Service for triggering application hooks
|
|
995
|
+
*/
|
|
996
|
+
private gHooksService;
|
|
997
|
+
/**
|
|
998
|
+
* Internal router context that stores all registered routes
|
|
999
|
+
* @private
|
|
1000
|
+
*/
|
|
1001
|
+
private fRouterContext;
|
|
1002
|
+
/**
|
|
1003
|
+
* Registers a new route in the router
|
|
1004
|
+
*
|
|
1005
|
+
* @param {RouterTypes.Route} route - The route configuration to add
|
|
1006
|
+
* @throws {Error} If router is not initialized
|
|
1007
|
+
*/
|
|
1008
|
+
addRoute(route: RouterTypes.Route): void;
|
|
1009
|
+
/**
|
|
1010
|
+
* Initializes the router and triggers related hooks
|
|
1011
|
+
*
|
|
1012
|
+
* This method creates a new router context and triggers
|
|
1013
|
+
* the before and after initialization hooks.
|
|
1014
|
+
*/
|
|
1015
|
+
initialize(): void;
|
|
1016
|
+
/**
|
|
1017
|
+
* Resolves a route based on the HTTP method and path
|
|
1018
|
+
*
|
|
1019
|
+
* @param {RouterTypes.RouteFind} route - The route to resolve
|
|
1020
|
+
* @returns {RouterTypes.RouteMatched<RouterTypes.RouterHandler> | undefined} The matched route or undefined if no match found
|
|
1021
|
+
*/
|
|
1022
|
+
resolve(route: RouterTypes.RouteFind): RouterTypes.RouteMatched<RouterTypes.RouterHandler> | undefined;
|
|
1023
|
+
}
|
|
1024
|
+
//#endregion
|
|
1025
|
+
//#region src/Errors/HttpError.d.ts
|
|
1026
|
+
/**
|
|
1027
|
+
* Represents an HTTP error.
|
|
1028
|
+
* @extends {Error}
|
|
1029
|
+
*/
|
|
1030
|
+
declare class HttpError extends Error {
|
|
1031
|
+
/**
|
|
1032
|
+
* The HTTP status code associated with the error.
|
|
1033
|
+
* @type {number}
|
|
1034
|
+
*/
|
|
1035
|
+
status: number;
|
|
1036
|
+
/**
|
|
1037
|
+
* Creates an instance of HttpError.
|
|
1038
|
+
* @param {number} status - The HTTP status code.
|
|
1039
|
+
* @param {string} [message] - The error message.
|
|
1040
|
+
*/
|
|
1041
|
+
constructor(status: number, message?: string);
|
|
1042
|
+
}
|
|
1043
|
+
//#endregion
|
|
1044
|
+
//#region src/Errors/Http/BadRequestError.d.ts
|
|
1045
|
+
/**
|
|
1046
|
+
* Represents a Bad Request error (HTTP 400).
|
|
1047
|
+
* @extends {HttpError}
|
|
1048
|
+
*/
|
|
1049
|
+
declare class BadRequestError extends HttpError {
|
|
1050
|
+
/**
|
|
1051
|
+
* The name of the error.
|
|
1052
|
+
* @type {string}
|
|
1053
|
+
*/
|
|
1054
|
+
name: string;
|
|
1055
|
+
/**
|
|
1056
|
+
* Creates an instance of BadRequestError.
|
|
1057
|
+
* @param {string} [message] - The error message.
|
|
1058
|
+
*/
|
|
1059
|
+
constructor(message?: string, errors?: any);
|
|
1060
|
+
}
|
|
1061
|
+
//#endregion
|
|
1062
|
+
//#region src/Errors/Http/ForbiddenError.d.ts
|
|
1063
|
+
/**
|
|
1064
|
+
* Represents a Forbidden error (HTTP 403).
|
|
1065
|
+
* @extends {HttpError}
|
|
1066
|
+
*/
|
|
1067
|
+
declare class ForbiddenError extends HttpError {
|
|
1068
|
+
/**
|
|
1069
|
+
* The name of the error.
|
|
1070
|
+
* @type {string}
|
|
1071
|
+
*/
|
|
1072
|
+
name: string;
|
|
1073
|
+
/**
|
|
1074
|
+
* Creates an instance of ForbiddenError.
|
|
1075
|
+
* @param {string} [message] - The error message.
|
|
1076
|
+
*/
|
|
1077
|
+
constructor(message?: string);
|
|
1078
|
+
}
|
|
1079
|
+
//#endregion
|
|
1080
|
+
//#region src/Errors/Http/InternalServerError.d.ts
|
|
1081
|
+
/**
|
|
1082
|
+
* Represents an Internal Server error (HTTP 500).
|
|
1083
|
+
* @extends {HttpError}
|
|
1084
|
+
*/
|
|
1085
|
+
declare class InternalServerError extends HttpError {
|
|
1086
|
+
/**
|
|
1087
|
+
* The name of the error.
|
|
1088
|
+
* @type {string}
|
|
1089
|
+
*/
|
|
1090
|
+
name: string;
|
|
1091
|
+
/**
|
|
1092
|
+
* Creates an instance of InternalServerError.
|
|
1093
|
+
* @param {string} [message] - The error message.
|
|
1094
|
+
*/
|
|
1095
|
+
constructor(message?: string);
|
|
1096
|
+
}
|
|
1097
|
+
//#endregion
|
|
1098
|
+
//#region src/Errors/Http/MethodNotAllowedError.d.ts
|
|
1099
|
+
/**
|
|
1100
|
+
* Represents a Method Not Allowed error (HTTP 405).
|
|
1101
|
+
* @extends {HttpError}
|
|
1102
|
+
*/
|
|
1103
|
+
declare class MethodNotAllowedError extends HttpError {
|
|
1104
|
+
/**
|
|
1105
|
+
* The name of the error.
|
|
1106
|
+
* @type {string}
|
|
1107
|
+
*/
|
|
1108
|
+
name: string;
|
|
1109
|
+
/**
|
|
1110
|
+
* Creates an instance of MethodNotAllowedError.
|
|
1111
|
+
* @param {string} [message] - The error message.
|
|
1112
|
+
*/
|
|
1113
|
+
constructor(message?: string);
|
|
1114
|
+
}
|
|
1115
|
+
//#endregion
|
|
1116
|
+
//#region src/Errors/Http/NotAcceptableError.d.ts
|
|
1117
|
+
/**
|
|
1118
|
+
* Represents a Not Acceptable error (HTTP 406).
|
|
1119
|
+
* @extends {HttpError}
|
|
1120
|
+
*/
|
|
1121
|
+
declare class NotAcceptableError extends HttpError {
|
|
1122
|
+
/**
|
|
1123
|
+
* The name of the error.
|
|
1124
|
+
* @type {string}
|
|
1125
|
+
*/
|
|
1126
|
+
name: string;
|
|
1127
|
+
/**
|
|
1128
|
+
* Creates an instance of NotAcceptableError.
|
|
1129
|
+
* @param {string} [message] - The error message.
|
|
1130
|
+
*/
|
|
1131
|
+
constructor(message?: string);
|
|
1132
|
+
}
|
|
1133
|
+
//#endregion
|
|
1134
|
+
//#region src/Errors/Http/NotFoundError.d.ts
|
|
1135
|
+
/**
|
|
1136
|
+
* Represents a Not Found error (HTTP 404).
|
|
1137
|
+
* @extends {HttpError}
|
|
1138
|
+
*/
|
|
1139
|
+
declare class NotFoundError extends HttpError {
|
|
1140
|
+
/**
|
|
1141
|
+
* The name of the error.
|
|
1142
|
+
* @type {string}
|
|
1143
|
+
*/
|
|
1144
|
+
name: string;
|
|
1145
|
+
/**
|
|
1146
|
+
* Creates an instance of NotFoundError.
|
|
1147
|
+
* @param {string} [message] - The error message.
|
|
1148
|
+
*/
|
|
1149
|
+
constructor(message?: string);
|
|
1150
|
+
}
|
|
1151
|
+
//#endregion
|
|
1152
|
+
//#region src/Errors/Http/UnauthorizedError.d.ts
|
|
1153
|
+
/**
|
|
1154
|
+
* Represents an Unauthorized error (HTTP 401).
|
|
1155
|
+
* @extends {HttpError}
|
|
1156
|
+
*/
|
|
1157
|
+
declare class UnauthorizedError extends HttpError {
|
|
1158
|
+
/**
|
|
1159
|
+
* The name of the error.
|
|
1160
|
+
* @type {string}
|
|
1161
|
+
*/
|
|
1162
|
+
name: string;
|
|
1163
|
+
/**
|
|
1164
|
+
* Creates an instance of UnauthorizedError.
|
|
1165
|
+
* @param {string} [message] - The error message.
|
|
1166
|
+
*/
|
|
1167
|
+
constructor(message?: string);
|
|
1168
|
+
}
|
|
1169
|
+
//#endregion
|
|
1170
|
+
//#region src/Utils/Utils.d.ts
|
|
1171
|
+
/**
|
|
1172
|
+
* Creates a new metadata context.
|
|
1173
|
+
* @returns {MetadataTypes.Ctx} The new metadata context.
|
|
1174
|
+
*/
|
|
1175
|
+
declare function createMetadataCtx(): MetadataTypes.Ctx;
|
|
1176
|
+
/**
|
|
1177
|
+
* Creates a new metadata method.
|
|
1178
|
+
* @returns {MetadataTypes.Method} The new metadata method.
|
|
1179
|
+
*/
|
|
1180
|
+
declare function createMetadataMethod(): MetadataTypes.Method;
|
|
1181
|
+
/**
|
|
1182
|
+
* Initializes the metadata for a given target and property name.
|
|
1183
|
+
* @param {any} target - The target to initialize metadata for.
|
|
1184
|
+
* @param {string} propertyName - The name of the property to initialize metadata for.
|
|
1185
|
+
*/
|
|
1186
|
+
declare function initializeMetadataMethod(target: any, propertyName: string): MetadataTypes.Method;
|
|
1187
|
+
/**
|
|
1188
|
+
* Initializes the metadata for a given target.
|
|
1189
|
+
* @param {any} target - The target to initialize metadata for.
|
|
1190
|
+
*/
|
|
1191
|
+
declare function initializeMetadata(target: any): MetadataTypes.Ctx;
|
|
1192
|
+
//#endregion
|
|
1193
|
+
export { App, BadRequestError, BaseMiddleware, BasePlugin, Body, ConfigTypes, Connect, Controller, Delete, ErrorHandlerProvider, FastResponse, ForbiddenError, Get, GlobalMiddlewareRegistry, HTTPStatus, Head, Header, Headers, HooksService, HooksTypes, HttpError, HttpServer, InternalServerError, Listen, MaybePromise, MetadataResolver, MetadataTypes, MethodNotAllowedError, Middleware$1 as Middleware, MiddlewareOptions, MultipartFormData, NotAcceptableError, NotFoundError, Options, Param, Patch, Post, Put, QueryParam, QueryParams, Redirect, Request$1 as Request, Response$1 as Response, Router, RouterTypes, Session, SetHeader, Status, Trace, UnauthorizedError, createApp, createMetadataCtx, createMetadataMethod, defineConfig, initializeMetadata, initializeMetadataMethod, loadVercubeConfig };
|