@vercube/core 0.0.1 → 0.0.2-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Services/ErrorHandler/DefaultErrorHandlerProvider.d.ts +1 -1
- package/dist/Services/HttpServer/HttpServer.d.ts +4 -4
- package/dist/Services/Router/RequestHandler.d.ts +0 -2
- package/dist/Types/HttpTypes.d.ts +1 -1
- package/dist/index.cjs +671 -21
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +669 -21
- package/package.json +7 -7
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { BaseLogger, Logger } from "@vercube/logger";
|
|
|
8
8
|
import { loadConfig } from "c12";
|
|
9
9
|
import { defu } from "defu";
|
|
10
10
|
|
|
11
|
-
//#region node_modules/.pnpm/@oxc-project+runtime@0.
|
|
11
|
+
//#region node_modules/.pnpm/@oxc-project+runtime@0.65.0/node_modules/@oxc-project/runtime/src/helpers/esm/decorate.js
|
|
12
12
|
function __decorate(decorators, target, key, desc) {
|
|
13
13
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
14
14
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -56,6 +56,9 @@ __decorate([Inject(Container)], PluginsRegistry.prototype, "gContainer", void 0)
|
|
|
56
56
|
|
|
57
57
|
//#endregion
|
|
58
58
|
//#region packages/core/src/Services/Hooks/HooksService.ts
|
|
59
|
+
/**
|
|
60
|
+
* This class is responsible for managing events.
|
|
61
|
+
*/
|
|
59
62
|
var HooksService = class {
|
|
60
63
|
fLastId = 0;
|
|
61
64
|
fHandlers = new Map();
|
|
@@ -171,6 +174,13 @@ var RouterAfterInitHook = class {};
|
|
|
171
174
|
|
|
172
175
|
//#endregion
|
|
173
176
|
//#region packages/core/src/Services/Router/Router.ts
|
|
177
|
+
/**
|
|
178
|
+
* Router service responsible for managing application routes
|
|
179
|
+
*
|
|
180
|
+
* This class provides functionality to initialize the router,
|
|
181
|
+
* register routes, and resolve incoming requests to their
|
|
182
|
+
* appropriate handlers.
|
|
183
|
+
*/
|
|
174
184
|
var Router = class {
|
|
175
185
|
/**
|
|
176
186
|
* Service for triggering application hooks
|
|
@@ -220,12 +230,27 @@ __decorate([Inject(HooksService)], Router.prototype, "gHooksService", void 0);
|
|
|
220
230
|
|
|
221
231
|
//#endregion
|
|
222
232
|
//#region packages/core/src/Resolvers/RouterParam.ts
|
|
233
|
+
/**
|
|
234
|
+
* Resolves a router parameter from the event object
|
|
235
|
+
* @param param - The parameter name to resolve from the router event
|
|
236
|
+
* @param event - The router event object containing parameters
|
|
237
|
+
* @returns The resolved parameter value if it exists, null otherwise
|
|
238
|
+
* @example
|
|
239
|
+
* ```typescript
|
|
240
|
+
* const value = resolveRouterParam('id', routerEvent);
|
|
241
|
+
* // Returns the 'id' parameter value from routerEvent.params or null
|
|
242
|
+
* ```
|
|
243
|
+
*/
|
|
223
244
|
function resolveRouterParam(param, event) {
|
|
224
245
|
return event.params?.[param] ?? null;
|
|
225
246
|
}
|
|
226
247
|
|
|
227
248
|
//#endregion
|
|
228
249
|
//#region packages/core/src/Errors/HttpError.ts
|
|
250
|
+
/**
|
|
251
|
+
* Represents an HTTP error.
|
|
252
|
+
* @extends {Error}
|
|
253
|
+
*/
|
|
229
254
|
var HttpError = class HttpError extends Error {
|
|
230
255
|
/**
|
|
231
256
|
* The HTTP status code associated with the error.
|
|
@@ -248,6 +273,10 @@ var HttpError = class HttpError extends Error {
|
|
|
248
273
|
|
|
249
274
|
//#endregion
|
|
250
275
|
//#region packages/core/src/Errors/Http/BadRequestError.ts
|
|
276
|
+
/**
|
|
277
|
+
* Represents a Bad Request error (HTTP 400).
|
|
278
|
+
* @extends {HttpError}
|
|
279
|
+
*/
|
|
251
280
|
var BadRequestError = class BadRequestError extends HttpError {
|
|
252
281
|
/**
|
|
253
282
|
* The name of the error.
|
|
@@ -268,6 +297,26 @@ var BadRequestError = class BadRequestError extends HttpError {
|
|
|
268
297
|
|
|
269
298
|
//#endregion
|
|
270
299
|
//#region packages/core/src/Resolvers/Body.ts
|
|
300
|
+
/**
|
|
301
|
+
* Resolves and parses the request body from a RouterEvent.
|
|
302
|
+
*
|
|
303
|
+
* @param {RouterTypes.RouterEvent} event - The router event containing the request to process
|
|
304
|
+
* @returns {Promise<unknown>} A promise that resolves to:
|
|
305
|
+
* - The parsed JSON body if the request contains valid JSON
|
|
306
|
+
* - undefined if the request body is empty
|
|
307
|
+
* @throws {BadRequestError} If the request body contains invalid JSON
|
|
308
|
+
*
|
|
309
|
+
* @example
|
|
310
|
+
* const body = await resolveRequestBody(event);
|
|
311
|
+
* if (body) {
|
|
312
|
+
* // Process the parsed body
|
|
313
|
+
* }
|
|
314
|
+
*
|
|
315
|
+
* @remarks
|
|
316
|
+
* - Currently only supports JSON content type
|
|
317
|
+
* - Returns undefined for empty request bodies
|
|
318
|
+
* - Throws BadRequestError for malformed JSON
|
|
319
|
+
*/
|
|
271
320
|
async function resolveRequestBody(event) {
|
|
272
321
|
const text = await event.request.text();
|
|
273
322
|
if (!text) return void 0;
|
|
@@ -280,10 +329,21 @@ async function resolveRequestBody(event) {
|
|
|
280
329
|
|
|
281
330
|
//#endregion
|
|
282
331
|
//#region packages/core/src/Resolvers/Query.ts
|
|
332
|
+
/**
|
|
333
|
+
* Resolves a single query parameter from the URL of a router event
|
|
334
|
+
* @param name - The name of the query parameter to resolve
|
|
335
|
+
* @param event - The router event containing the request URL
|
|
336
|
+
* @returns The value of the query parameter if found, null otherwise
|
|
337
|
+
*/
|
|
283
338
|
function resolveQueryParam(name, event) {
|
|
284
339
|
const url = new URL(event.request.url);
|
|
285
340
|
return url.searchParams.get(name);
|
|
286
341
|
}
|
|
342
|
+
/**
|
|
343
|
+
* Resolves all query parameters from the URL of a router event
|
|
344
|
+
* @param event - The router event containing the request URL
|
|
345
|
+
* @returns An object containing all query parameters as key-value pairs
|
|
346
|
+
*/
|
|
287
347
|
function resolveQueryParams(event) {
|
|
288
348
|
const url = new URL(event.request.url);
|
|
289
349
|
const params = {};
|
|
@@ -293,15 +353,29 @@ function resolveQueryParams(event) {
|
|
|
293
353
|
|
|
294
354
|
//#endregion
|
|
295
355
|
//#region packages/core/src/Resolvers/Headers.ts
|
|
356
|
+
/**
|
|
357
|
+
* Retrieves a specific header value from the request
|
|
358
|
+
* @param {string} header - The name of the header to retrieve
|
|
359
|
+
* @param {RouterTypes.RouterEvent} event - The router event containing the request
|
|
360
|
+
* @returns {string | null} The header value if found, null otherwise
|
|
361
|
+
*/
|
|
296
362
|
function getRequestHeader(header, event) {
|
|
297
363
|
return event.request.headers.get(header);
|
|
298
364
|
}
|
|
365
|
+
/**
|
|
366
|
+
* Retrieves all headers from the request
|
|
367
|
+
* @param {RouterTypes.RouterEvent} event - The router event containing the request
|
|
368
|
+
* @returns {Headers} The complete Headers object from the request
|
|
369
|
+
*/
|
|
299
370
|
function getRequestHeaders(event) {
|
|
300
371
|
return event.request.headers;
|
|
301
372
|
}
|
|
302
373
|
|
|
303
374
|
//#endregion
|
|
304
375
|
//#region packages/core/src/Services/Metadata/MetadataResolver.ts
|
|
376
|
+
/**
|
|
377
|
+
* Class responsible for resolving metadata for route handlers.
|
|
378
|
+
*/
|
|
305
379
|
var MetadataResolver = class {
|
|
306
380
|
/**
|
|
307
381
|
* Resolves the URL for a given instance and path.
|
|
@@ -377,10 +451,24 @@ var MetadataResolver = class {
|
|
|
377
451
|
|
|
378
452
|
//#endregion
|
|
379
453
|
//#region packages/core/src/Services/ErrorHandler/ErrorHandlerProvider.ts
|
|
454
|
+
/**
|
|
455
|
+
* Abstract class representing an error handler provider
|
|
456
|
+
* Provides a common interface for different error handler implementations
|
|
457
|
+
*
|
|
458
|
+
* @abstract
|
|
459
|
+
* @class ErrorHandlerProvider
|
|
460
|
+
*/
|
|
380
461
|
var ErrorHandlerProvider = class {};
|
|
381
462
|
|
|
382
463
|
//#endregion
|
|
383
464
|
//#region packages/core/src/Services/Middleware/GlobalMiddlewareRegistry.ts
|
|
465
|
+
/**
|
|
466
|
+
* Manages global middleware registration and retrieval
|
|
467
|
+
*
|
|
468
|
+
* This class provides functionality to register and retrieve global middleware
|
|
469
|
+
* configurations. It allows for adding middleware with specific options and
|
|
470
|
+
* retrieving them in a standardized format.
|
|
471
|
+
*/
|
|
384
472
|
var GlobalMiddlewareRegistry = class {
|
|
385
473
|
fMiddlewares = new Set();
|
|
386
474
|
/**
|
|
@@ -412,13 +500,20 @@ var GlobalMiddlewareRegistry = class {
|
|
|
412
500
|
|
|
413
501
|
//#endregion
|
|
414
502
|
//#region packages/core/src/Services/Router/RequestHandler.ts
|
|
503
|
+
/**
|
|
504
|
+
* Handles HTTP requests by preparing and executing route handlers with their associated middlewares
|
|
505
|
+
*
|
|
506
|
+
* The RequestHandler is responsible for:
|
|
507
|
+
* - Preparing route handlers with their metadata
|
|
508
|
+
* - Executing middleware chains (before and after)
|
|
509
|
+
* - Processing request/response lifecycle
|
|
510
|
+
* - Error handling during request processing
|
|
511
|
+
*/
|
|
415
512
|
var RequestHandler = class {
|
|
416
513
|
/** Resolver for extracting metadata from controller classes and methods */
|
|
417
514
|
gMetadataResolver;
|
|
418
515
|
/** DI container for resolving dependencies */
|
|
419
516
|
gContainer;
|
|
420
|
-
/** Provider for handling errors during request processing */
|
|
421
|
-
gErrorHandlerProvider;
|
|
422
517
|
gGlobalMiddlewareRegistry;
|
|
423
518
|
/**
|
|
424
519
|
* Prepares a route handler by resolving its metadata and middlewares
|
|
@@ -477,8 +572,8 @@ var RequestHandler = class {
|
|
|
477
572
|
methodArgs: args
|
|
478
573
|
});
|
|
479
574
|
if (hookResponse instanceof Response) return hookResponse;
|
|
480
|
-
} catch (
|
|
481
|
-
|
|
575
|
+
} catch (error_) {
|
|
576
|
+
this.gContainer.get(ErrorHandlerProvider).handleError(error_);
|
|
482
577
|
}
|
|
483
578
|
for (const action of actions) {
|
|
484
579
|
const actionResponse = action.handler(request, fakeResponse);
|
|
@@ -494,8 +589,8 @@ var RequestHandler = class {
|
|
|
494
589
|
for await (const hook of middlewares?.afterMiddlewares ?? []) try {
|
|
495
590
|
const hookResponse = await hook.middleware.onResponse?.(request, fakeResponse, handlerResponse);
|
|
496
591
|
if (hookResponse !== null) fakeResponse = this.processOverrideResponse(hookResponse, fakeResponse);
|
|
497
|
-
} catch (
|
|
498
|
-
|
|
592
|
+
} catch (error_) {
|
|
593
|
+
this.gContainer.get(ErrorHandlerProvider).handleError(error_);
|
|
499
594
|
}
|
|
500
595
|
const body = fakeResponse?.body ?? JSON.stringify(handlerResponse);
|
|
501
596
|
return new Response(body, {
|
|
@@ -504,7 +599,7 @@ var RequestHandler = class {
|
|
|
504
599
|
headers: fakeResponse.headers
|
|
505
600
|
});
|
|
506
601
|
} catch (error_) {
|
|
507
|
-
return this.
|
|
602
|
+
return this.gContainer.get(ErrorHandlerProvider).handleError(error_);
|
|
508
603
|
}
|
|
509
604
|
}
|
|
510
605
|
/**
|
|
@@ -535,7 +630,6 @@ var RequestHandler = class {
|
|
|
535
630
|
};
|
|
536
631
|
__decorate([Inject(MetadataResolver)], RequestHandler.prototype, "gMetadataResolver", void 0);
|
|
537
632
|
__decorate([Inject(Container)], RequestHandler.prototype, "gContainer", void 0);
|
|
538
|
-
__decorate([Inject(ErrorHandlerProvider)], RequestHandler.prototype, "gErrorHandlerProvider", void 0);
|
|
539
633
|
__decorate([Inject(GlobalMiddlewareRegistry)], RequestHandler.prototype, "gGlobalMiddlewareRegistry", void 0);
|
|
540
634
|
|
|
541
635
|
//#endregion
|
|
@@ -558,6 +652,15 @@ const mime = { getType(ext) {
|
|
|
558
652
|
|
|
559
653
|
//#endregion
|
|
560
654
|
//#region packages/core/src/Services/Router/StaticRequestHandler.ts
|
|
655
|
+
/**
|
|
656
|
+
* Handles serving static files over HTTP
|
|
657
|
+
*
|
|
658
|
+
* The StaticRequestHandler is responsible for:
|
|
659
|
+
* - Serving static files from configured directories
|
|
660
|
+
* - Setting appropriate content types and headers
|
|
661
|
+
* - Handling caching and ETags
|
|
662
|
+
* - Processing GET requests for static assets
|
|
663
|
+
*/
|
|
561
664
|
var StaticRequestHandler = class {
|
|
562
665
|
/**
|
|
563
666
|
* The options for the static server
|
|
@@ -623,7 +726,19 @@ var StaticRequestHandler = class {
|
|
|
623
726
|
|
|
624
727
|
//#endregion
|
|
625
728
|
//#region packages/core/src/Services/HttpServer/HttpServer.ts
|
|
729
|
+
/**
|
|
730
|
+
* HTTP server implementation for handling incoming web requests
|
|
731
|
+
*
|
|
732
|
+
* This class is responsible for:
|
|
733
|
+
* - Initializing and managing the HTTP server
|
|
734
|
+
* - Routing incoming requests to appropriate handlers
|
|
735
|
+
* - Processing HTTP responses
|
|
736
|
+
*/
|
|
626
737
|
var HttpServer = class {
|
|
738
|
+
/**
|
|
739
|
+
* DI container for resolving dependencies
|
|
740
|
+
*/
|
|
741
|
+
gContainer;
|
|
627
742
|
/**
|
|
628
743
|
* Router service for resolving routes
|
|
629
744
|
*/
|
|
@@ -633,10 +748,6 @@ var HttpServer = class {
|
|
|
633
748
|
*/
|
|
634
749
|
gRequestHandler;
|
|
635
750
|
/**
|
|
636
|
-
* Error handler provider for managing error responses
|
|
637
|
-
*/
|
|
638
|
-
gErrorHandlerProvider;
|
|
639
|
-
/**
|
|
640
751
|
* Static server for serving static files
|
|
641
752
|
*/
|
|
642
753
|
gStaticRequestHandler;
|
|
@@ -654,10 +765,10 @@ var HttpServer = class {
|
|
|
654
765
|
const { port, host } = config.server ?? {};
|
|
655
766
|
this.fServer = serve({
|
|
656
767
|
bun: { error: (error) => {
|
|
657
|
-
return this.
|
|
768
|
+
return this.gContainer.get(ErrorHandlerProvider).handleError(error);
|
|
658
769
|
} },
|
|
659
770
|
deno: { onError: (error) => {
|
|
660
|
-
return this.
|
|
771
|
+
return this.gContainer.get(ErrorHandlerProvider).handleError(error);
|
|
661
772
|
} },
|
|
662
773
|
hostname: host,
|
|
663
774
|
port,
|
|
@@ -697,17 +808,20 @@ var HttpServer = class {
|
|
|
697
808
|
}
|
|
698
809
|
return this.gRequestHandler.handleRequest(request, route);
|
|
699
810
|
} catch (error) {
|
|
700
|
-
return this.
|
|
811
|
+
return this.gContainer.get(ErrorHandlerProvider).handleError(error);
|
|
701
812
|
}
|
|
702
813
|
}
|
|
703
814
|
};
|
|
815
|
+
__decorate([Inject(Container)], HttpServer.prototype, "gContainer", void 0);
|
|
704
816
|
__decorate([Inject(Router)], HttpServer.prototype, "gRouter", void 0);
|
|
705
817
|
__decorate([Inject(RequestHandler)], HttpServer.prototype, "gRequestHandler", void 0);
|
|
706
|
-
__decorate([Inject(ErrorHandlerProvider)], HttpServer.prototype, "gErrorHandlerProvider", void 0);
|
|
707
818
|
__decorate([Inject(StaticRequestHandler)], HttpServer.prototype, "gStaticRequestHandler", void 0);
|
|
708
819
|
|
|
709
820
|
//#endregion
|
|
710
821
|
//#region packages/core/src/Common/App.ts
|
|
822
|
+
/**
|
|
823
|
+
* Represents the main application class.
|
|
824
|
+
*/
|
|
711
825
|
var App = class {
|
|
712
826
|
gRouter;
|
|
713
827
|
gPluginsRegistry;
|
|
@@ -784,6 +898,13 @@ __decorate([Inject(StaticRequestHandler)], App.prototype, "gStaticRequestHandler
|
|
|
784
898
|
|
|
785
899
|
//#endregion
|
|
786
900
|
//#region packages/logger/dist/Providers/index.mjs
|
|
901
|
+
/**
|
|
902
|
+
* Abstract base class for implementing log provider.
|
|
903
|
+
* Providers are responsible for processing and outputting log messages to various destinations.
|
|
904
|
+
* Each appender can be initialized with custom options and handles message processing according to its implementation.
|
|
905
|
+
*
|
|
906
|
+
* @template T - The type of options used to initialize the appender
|
|
907
|
+
*/
|
|
787
908
|
var LoggerProvider = class {};
|
|
788
909
|
const isColorAllowed = () => !process.env.NO_COLOR;
|
|
789
910
|
const colorIfAllowed = (colorFn) => {
|
|
@@ -806,6 +927,9 @@ const LOG_LEVEL_COLORS = {
|
|
|
806
927
|
warn: colors.yellow,
|
|
807
928
|
error: colors.red
|
|
808
929
|
};
|
|
930
|
+
/**
|
|
931
|
+
* ConsoleProvider class for logging messages to the console.
|
|
932
|
+
*/
|
|
809
933
|
var ConsoleProvider = class extends LoggerProvider {
|
|
810
934
|
/**
|
|
811
935
|
* Initializes the appender with the provided options.
|
|
@@ -825,10 +949,23 @@ var ConsoleProvider = class extends LoggerProvider {
|
|
|
825
949
|
|
|
826
950
|
//#endregion
|
|
827
951
|
//#region packages/core/src/Services/Validation/ValidationProvider.ts
|
|
952
|
+
/**
|
|
953
|
+
* Abstract class representing a validation provider
|
|
954
|
+
* Provides a common interface for different validation implementations
|
|
955
|
+
*
|
|
956
|
+
* @abstract
|
|
957
|
+
* @class ValidationProvider
|
|
958
|
+
*/
|
|
828
959
|
var ValidationProvider = class {};
|
|
829
960
|
|
|
830
961
|
//#endregion
|
|
831
962
|
//#region packages/core/src/Services/Validation/StandardSchemaValidationProvider.ts
|
|
963
|
+
/**
|
|
964
|
+
* StandardSchemaValidationProvider implements validation using StandardSchema schema validation
|
|
965
|
+
* @see https://github.com/standard-schema/standard-schema
|
|
966
|
+
* @class
|
|
967
|
+
* @implements {ValidationProvider}
|
|
968
|
+
*/
|
|
832
969
|
var StandardSchemaValidationProvider = class {
|
|
833
970
|
/**
|
|
834
971
|
* Validates data against a schema
|
|
@@ -843,6 +980,10 @@ var StandardSchemaValidationProvider = class {
|
|
|
843
980
|
|
|
844
981
|
//#endregion
|
|
845
982
|
//#region packages/core/src/Services/Config/RuntimeConfig.ts
|
|
983
|
+
/**
|
|
984
|
+
* RuntimeConfig class manages the runtime configuration for the Vercube application.
|
|
985
|
+
* This class provides a centralized way to access and modify runtime configuration settings.
|
|
986
|
+
*/
|
|
846
987
|
var RuntimeConfig = class {
|
|
847
988
|
/**
|
|
848
989
|
* Private field to store the runtime configuration object.
|
|
@@ -867,6 +1008,10 @@ var RuntimeConfig = class {
|
|
|
867
1008
|
|
|
868
1009
|
//#endregion
|
|
869
1010
|
//#region packages/core/src/Errors/Http/InternalServerError.ts
|
|
1011
|
+
/**
|
|
1012
|
+
* Represents an Internal Server error (HTTP 500).
|
|
1013
|
+
* @extends {HttpError}
|
|
1014
|
+
*/
|
|
870
1015
|
var InternalServerError = class InternalServerError extends HttpError {
|
|
871
1016
|
/**
|
|
872
1017
|
* The name of the error.
|
|
@@ -886,26 +1031,36 @@ var InternalServerError = class InternalServerError extends HttpError {
|
|
|
886
1031
|
|
|
887
1032
|
//#endregion
|
|
888
1033
|
//#region packages/core/src/Services/ErrorHandler/DefaultErrorHandlerProvider.ts
|
|
1034
|
+
/**
|
|
1035
|
+
* Default error handler provider
|
|
1036
|
+
*
|
|
1037
|
+
* @class DefaultErrorHandlerProvider
|
|
1038
|
+
*/
|
|
889
1039
|
var DefaultErrorHandlerProvider = class extends ErrorHandlerProvider {
|
|
890
1040
|
gLogger;
|
|
891
1041
|
/**
|
|
892
1042
|
* Handles an error that occurred during request processing
|
|
893
|
-
*
|
|
1043
|
+
*
|
|
894
1044
|
* @param error - The Error object containing error details
|
|
895
1045
|
* @returns Promise<Response> | Response - The response to be sent to the client
|
|
896
1046
|
*/
|
|
897
1047
|
handleError(error) {
|
|
898
|
-
const _internalError = new InternalServerError();
|
|
1048
|
+
const _internalError = new InternalServerError(error?.message ?? "Internal server error");
|
|
899
1049
|
const status = error?.status ?? 500;
|
|
900
1050
|
if (error instanceof HttpError) return new Response(JSON.stringify({ ...error }, void 0, 2), { status });
|
|
901
1051
|
this.gLogger.error(error);
|
|
902
|
-
return new Response(JSON.stringify({ ...error?.cause ?? _internalError
|
|
1052
|
+
return new Response(JSON.stringify({ ...error?.cause ?? _internalError }, void 0, 2), { status });
|
|
903
1053
|
}
|
|
904
1054
|
};
|
|
905
1055
|
__decorate([Inject(Logger)], DefaultErrorHandlerProvider.prototype, "gLogger", void 0);
|
|
906
1056
|
|
|
907
1057
|
//#endregion
|
|
908
1058
|
//#region packages/core/src/Common/Container.ts
|
|
1059
|
+
/**
|
|
1060
|
+
* Creates and configures a new dependency injection container for the application.
|
|
1061
|
+
*
|
|
1062
|
+
* @returns {Container} A configured dependency injection container.
|
|
1063
|
+
*/
|
|
909
1064
|
function createContainer(config) {
|
|
910
1065
|
const container = new Container();
|
|
911
1066
|
container.bindInstance(Container, container);
|
|
@@ -933,6 +1088,10 @@ function createContainer(config) {
|
|
|
933
1088
|
|
|
934
1089
|
//#endregion
|
|
935
1090
|
//#region packages/core/src/Utils/InternalUtils.ts
|
|
1091
|
+
/**
|
|
1092
|
+
* Generate random hash
|
|
1093
|
+
* @returns string
|
|
1094
|
+
*/
|
|
936
1095
|
function generateRandomHash() {
|
|
937
1096
|
const hashByPerformance = Math.floor(Date.now() * 1e3).toString(16);
|
|
938
1097
|
const hashByMath = () => (Math.floor(Math.random() * 16777215) | 1048576).toString(16);
|
|
@@ -941,6 +1100,10 @@ function generateRandomHash() {
|
|
|
941
1100
|
|
|
942
1101
|
//#endregion
|
|
943
1102
|
//#region packages/core/src/Config/DefaultConfig.ts
|
|
1103
|
+
/**
|
|
1104
|
+
* Default configuration for the Vercube application.
|
|
1105
|
+
* This configuration serves as the base settings and can be overridden by user configuration.
|
|
1106
|
+
*/
|
|
944
1107
|
const defaultConfig = {
|
|
945
1108
|
logLevel: "debug",
|
|
946
1109
|
production: false,
|
|
@@ -971,6 +1134,11 @@ const defaultConfig = {
|
|
|
971
1134
|
|
|
972
1135
|
//#endregion
|
|
973
1136
|
//#region packages/core/src/Config/Loader.ts
|
|
1137
|
+
/**
|
|
1138
|
+
* Loads the configuration object for the application
|
|
1139
|
+
* @param {ConfigTypes.Config} overrides - The configuration object to load
|
|
1140
|
+
* @returns {ConfigTypes.Config} The loaded configuration object
|
|
1141
|
+
*/
|
|
974
1142
|
async function loadVercubeConfig(overrides) {
|
|
975
1143
|
const config = await loadConfig({
|
|
976
1144
|
name: "vercube",
|
|
@@ -984,6 +1152,11 @@ async function loadVercubeConfig(overrides) {
|
|
|
984
1152
|
|
|
985
1153
|
//#endregion
|
|
986
1154
|
//#region packages/core/src/Common/CreateApp.ts
|
|
1155
|
+
/**
|
|
1156
|
+
* Creates and initializes an instance of the App.
|
|
1157
|
+
*
|
|
1158
|
+
* @returns {Promise<App>} A promise that resolves to an instance of the App.
|
|
1159
|
+
*/
|
|
987
1160
|
async function createApp(cfg) {
|
|
988
1161
|
const config = await loadVercubeConfig(cfg);
|
|
989
1162
|
const container = createContainer(config);
|
|
@@ -997,12 +1170,26 @@ async function createApp(cfg) {
|
|
|
997
1170
|
|
|
998
1171
|
//#endregion
|
|
999
1172
|
//#region packages/core/src/Config/Config.ts
|
|
1173
|
+
/**
|
|
1174
|
+
* Defines a configuration object for the application
|
|
1175
|
+
* @param {ConfigTypes.Config} config - The configuration object to validate
|
|
1176
|
+
* @returns {ConfigTypes.Config} The validated configuration object
|
|
1177
|
+
*/
|
|
1000
1178
|
function defineConfig(config) {
|
|
1001
1179
|
return config;
|
|
1002
1180
|
}
|
|
1003
1181
|
|
|
1004
1182
|
//#endregion
|
|
1005
1183
|
//#region packages/core/src/Middleware/ValidationMiddleware.ts
|
|
1184
|
+
/**
|
|
1185
|
+
* Middleware for validating request data against a schema
|
|
1186
|
+
* @class ValidationMiddleware
|
|
1187
|
+
* @implements {BaseMiddleware}
|
|
1188
|
+
* @description Validates incoming request data against a provided schema
|
|
1189
|
+
* @example
|
|
1190
|
+
* const middleware = new ValidationMiddleware();
|
|
1191
|
+
* await middleware.use(event, { schema: myValidationSchema });
|
|
1192
|
+
*/
|
|
1006
1193
|
var ValidationMiddleware = class {
|
|
1007
1194
|
gValidationProvider;
|
|
1008
1195
|
/**
|
|
@@ -1029,6 +1216,10 @@ __decorate([InjectOptional(ValidationProvider)], ValidationMiddleware.prototype,
|
|
|
1029
1216
|
|
|
1030
1217
|
//#endregion
|
|
1031
1218
|
//#region packages/core/src/Utils/Utils.ts
|
|
1219
|
+
/**
|
|
1220
|
+
* Creates a new metadata context.
|
|
1221
|
+
* @returns {MetadataTypes.Ctx} The new metadata context.
|
|
1222
|
+
*/
|
|
1032
1223
|
function createMetadataCtx() {
|
|
1033
1224
|
return {
|
|
1034
1225
|
__controller: { path: "" },
|
|
@@ -1036,6 +1227,10 @@ function createMetadataCtx() {
|
|
|
1036
1227
|
__methods: {}
|
|
1037
1228
|
};
|
|
1038
1229
|
}
|
|
1230
|
+
/**
|
|
1231
|
+
* Creates a new metadata method.
|
|
1232
|
+
* @returns {MetadataTypes.Method} The new metadata method.
|
|
1233
|
+
*/
|
|
1039
1234
|
function createMetadataMethod() {
|
|
1040
1235
|
return {
|
|
1041
1236
|
req: null,
|
|
@@ -1045,10 +1240,19 @@ function createMetadataMethod() {
|
|
|
1045
1240
|
actions: []
|
|
1046
1241
|
};
|
|
1047
1242
|
}
|
|
1243
|
+
/**
|
|
1244
|
+
* Initializes the metadata for a given target and property name.
|
|
1245
|
+
* @param {any} target - The target to initialize metadata for.
|
|
1246
|
+
* @param {string} propertyName - The name of the property to initialize metadata for.
|
|
1247
|
+
*/
|
|
1048
1248
|
function initializeMetadataMethod(target, propertyName) {
|
|
1049
1249
|
if (!target.__metadata.__methods[propertyName]) target.__metadata.__methods[propertyName] = createMetadataMethod();
|
|
1050
1250
|
return target.__metadata.__methods[propertyName];
|
|
1051
1251
|
}
|
|
1252
|
+
/**
|
|
1253
|
+
* Initializes the metadata for a given target.
|
|
1254
|
+
* @param {any} target - The target to initialize metadata for.
|
|
1255
|
+
*/
|
|
1052
1256
|
function initializeMetadata(target) {
|
|
1053
1257
|
if (!target.__metadata) target.__metadata = createMetadataCtx();
|
|
1054
1258
|
if (!target.__metadata.__methods) target.__metadata.__methods = {};
|
|
@@ -1058,6 +1262,12 @@ function initializeMetadata(target) {
|
|
|
1058
1262
|
|
|
1059
1263
|
//#endregion
|
|
1060
1264
|
//#region packages/core/src/Decorators/Http/Body.ts
|
|
1265
|
+
/**
|
|
1266
|
+
* @class BodyDecorator
|
|
1267
|
+
* @extends BaseDecorator<BodyDecoratorOptions>
|
|
1268
|
+
*
|
|
1269
|
+
* A decorator class that handles the metadata for HTTP request bodies.
|
|
1270
|
+
*/
|
|
1061
1271
|
var BodyDecorator = class extends BaseDecorator {
|
|
1062
1272
|
/**
|
|
1063
1273
|
* @method created
|
|
@@ -1081,12 +1291,30 @@ var BodyDecorator = class extends BaseDecorator {
|
|
|
1081
1291
|
});
|
|
1082
1292
|
}
|
|
1083
1293
|
};
|
|
1294
|
+
/**
|
|
1295
|
+
* @function Body
|
|
1296
|
+
* @returns {Function} A decorator function that registers the BodyDecorator.
|
|
1297
|
+
*
|
|
1298
|
+
* This function creates and returns a decorator that can be used to annotate
|
|
1299
|
+
* a parameter in a method to indicate that it should be populated with the
|
|
1300
|
+
* body of an HTTP request. The decorator uses the BodyDecorator class to
|
|
1301
|
+
* handle the metadata associated with the parameter.
|
|
1302
|
+
*/
|
|
1084
1303
|
function Body(options) {
|
|
1085
1304
|
return createDecorator(BodyDecorator, options);
|
|
1086
1305
|
}
|
|
1087
1306
|
|
|
1088
1307
|
//#endregion
|
|
1089
1308
|
//#region packages/core/src/Decorators/Http/Connect.ts
|
|
1309
|
+
/**
|
|
1310
|
+
* A decorator class for handling HTTP CONNECT requests.
|
|
1311
|
+
*
|
|
1312
|
+
* This class extends the BaseDecorator and is used to register CONNECT routes
|
|
1313
|
+
* with the Router. It also resolves metadata for the route handler
|
|
1314
|
+
* using the MetadataResolver.
|
|
1315
|
+
*
|
|
1316
|
+
* @extends {BaseDecorator<ConnectDecoratorOptions>}
|
|
1317
|
+
*/
|
|
1090
1318
|
var ConnectDecorator = class extends BaseDecorator {
|
|
1091
1319
|
gRouter;
|
|
1092
1320
|
gRequestHandler;
|
|
@@ -1116,12 +1344,30 @@ var ConnectDecorator = class extends BaseDecorator {
|
|
|
1116
1344
|
__decorate([Inject(Router)], ConnectDecorator.prototype, "gRouter", void 0);
|
|
1117
1345
|
__decorate([Inject(RequestHandler)], ConnectDecorator.prototype, "gRequestHandler", void 0);
|
|
1118
1346
|
__decorate([Inject(MetadataResolver)], ConnectDecorator.prototype, "gMetadataResolver", void 0);
|
|
1347
|
+
/**
|
|
1348
|
+
* A factory function for creating a ConnectDecorator.
|
|
1349
|
+
*
|
|
1350
|
+
* This function returns a decorator function that can be used to annotate
|
|
1351
|
+
* a method with CONNECT route information.
|
|
1352
|
+
*
|
|
1353
|
+
* @param {string} path - The path for the CONNECT route.
|
|
1354
|
+
* @return {Function} The decorator function.
|
|
1355
|
+
*/
|
|
1119
1356
|
function Connect(path) {
|
|
1120
1357
|
return createDecorator(ConnectDecorator, { path });
|
|
1121
1358
|
}
|
|
1122
1359
|
|
|
1123
1360
|
//#endregion
|
|
1124
1361
|
//#region packages/core/src/Decorators/Http/Controller.ts
|
|
1362
|
+
/**
|
|
1363
|
+
* A factory function for creating a Controller decorator.
|
|
1364
|
+
*
|
|
1365
|
+
* This function returns a decorator function that can be used to annotate
|
|
1366
|
+
* a class with controller metadata, including the base path for the controller.
|
|
1367
|
+
*
|
|
1368
|
+
* @param {string} path - The base path for the controller.
|
|
1369
|
+
* @return {Function} The decorator function.
|
|
1370
|
+
*/
|
|
1125
1371
|
function Controller(path) {
|
|
1126
1372
|
return function internalDecorator(target) {
|
|
1127
1373
|
const meta = initializeMetadata(target.prototype);
|
|
@@ -1134,6 +1380,15 @@ function Controller(path) {
|
|
|
1134
1380
|
|
|
1135
1381
|
//#endregion
|
|
1136
1382
|
//#region packages/core/src/Decorators/Http/Delete.ts
|
|
1383
|
+
/**
|
|
1384
|
+
* A decorator class for handling HTTP DELETE requests.
|
|
1385
|
+
*
|
|
1386
|
+
* This class extends the BaseDecorator and is used to register DELETE routes
|
|
1387
|
+
* with the Router. It also resolves metadata for the route handler
|
|
1388
|
+
* using the MetadataResolver.
|
|
1389
|
+
*
|
|
1390
|
+
* @extends {BaseDecorator<DeleteDecoratorOptions>}
|
|
1391
|
+
*/
|
|
1137
1392
|
var DeleteDecorator = class extends BaseDecorator {
|
|
1138
1393
|
gRouter;
|
|
1139
1394
|
gRequestHandler;
|
|
@@ -1165,12 +1420,30 @@ var DeleteDecorator = class extends BaseDecorator {
|
|
|
1165
1420
|
__decorate([Inject(Router)], DeleteDecorator.prototype, "gRouter", void 0);
|
|
1166
1421
|
__decorate([Inject(RequestHandler)], DeleteDecorator.prototype, "gRequestHandler", void 0);
|
|
1167
1422
|
__decorate([Inject(MetadataResolver)], DeleteDecorator.prototype, "gMetadataResolver", void 0);
|
|
1423
|
+
/**
|
|
1424
|
+
* A factory function for creating a DeleteDecorator.
|
|
1425
|
+
*
|
|
1426
|
+
* This function returns a decorator function that can be used to annotate
|
|
1427
|
+
* a method with DELETE route information.
|
|
1428
|
+
*
|
|
1429
|
+
* @param {string} path - The path for the DELETE route.
|
|
1430
|
+
* @return {Function} The decorator function.
|
|
1431
|
+
*/
|
|
1168
1432
|
function Delete(path) {
|
|
1169
1433
|
return createDecorator(DeleteDecorator, { path });
|
|
1170
1434
|
}
|
|
1171
1435
|
|
|
1172
1436
|
//#endregion
|
|
1173
1437
|
//#region packages/core/src/Decorators/Http/Get.ts
|
|
1438
|
+
/**
|
|
1439
|
+
* A decorator class for handling HTTP GET requests.
|
|
1440
|
+
*
|
|
1441
|
+
* This class extends the BaseDecorator and is used to register GET routes
|
|
1442
|
+
* with the Router. It also resolves metadata for the route handler
|
|
1443
|
+
* using the MetadataResolver.
|
|
1444
|
+
*
|
|
1445
|
+
* @extends {BaseDecorator<GetDecoratorOptions>}
|
|
1446
|
+
*/
|
|
1174
1447
|
var GetDecorator = class extends BaseDecorator {
|
|
1175
1448
|
gRouter;
|
|
1176
1449
|
gRequestHandler;
|
|
@@ -1202,12 +1475,30 @@ var GetDecorator = class extends BaseDecorator {
|
|
|
1202
1475
|
__decorate([Inject(Router)], GetDecorator.prototype, "gRouter", void 0);
|
|
1203
1476
|
__decorate([Inject(RequestHandler)], GetDecorator.prototype, "gRequestHandler", void 0);
|
|
1204
1477
|
__decorate([Inject(MetadataResolver)], GetDecorator.prototype, "gMetadataResolver", void 0);
|
|
1478
|
+
/**
|
|
1479
|
+
* A decorator function for handling HTTP GET requests.
|
|
1480
|
+
*
|
|
1481
|
+
* This function creates an instance of the GetDecorator class and registers
|
|
1482
|
+
* the GET route with the specified path.
|
|
1483
|
+
*
|
|
1484
|
+
* @param {string} path - The path for the GET route.
|
|
1485
|
+
* @returns {Function} - The decorator function.
|
|
1486
|
+
*/
|
|
1205
1487
|
function Get(path) {
|
|
1206
1488
|
return createDecorator(GetDecorator, { path });
|
|
1207
1489
|
}
|
|
1208
1490
|
|
|
1209
1491
|
//#endregion
|
|
1210
1492
|
//#region packages/core/src/Decorators/Http/Head.ts
|
|
1493
|
+
/**
|
|
1494
|
+
* A decorator class for handling HTTP HEAD requests.
|
|
1495
|
+
*
|
|
1496
|
+
* This class extends the BaseDecorator and is used to register HEAD routes
|
|
1497
|
+
* with the Router. It also resolves metadata for the route handler
|
|
1498
|
+
* using the MetadataResolver.
|
|
1499
|
+
*
|
|
1500
|
+
* @extends {BaseDecorator<HeadDecoratorOptions>}
|
|
1501
|
+
*/
|
|
1211
1502
|
var HeadDecorator = class extends BaseDecorator {
|
|
1212
1503
|
gRouter;
|
|
1213
1504
|
gRequestHandler;
|
|
@@ -1239,12 +1530,30 @@ var HeadDecorator = class extends BaseDecorator {
|
|
|
1239
1530
|
__decorate([Inject(Router)], HeadDecorator.prototype, "gRouter", void 0);
|
|
1240
1531
|
__decorate([Inject(RequestHandler)], HeadDecorator.prototype, "gRequestHandler", void 0);
|
|
1241
1532
|
__decorate([Inject(MetadataResolver)], HeadDecorator.prototype, "gMetadataResolver", void 0);
|
|
1533
|
+
/**
|
|
1534
|
+
* A factory function for creating a HeadDecorator.
|
|
1535
|
+
*
|
|
1536
|
+
* This function returns a decorator function that can be used to annotate
|
|
1537
|
+
* a method with HEAD route information.
|
|
1538
|
+
*
|
|
1539
|
+
* @param {string} path - The path for the HEAD route.
|
|
1540
|
+
* @return {Function} The decorator function.
|
|
1541
|
+
*/
|
|
1242
1542
|
function Head(path) {
|
|
1243
1543
|
return createDecorator(HeadDecorator, { path });
|
|
1244
1544
|
}
|
|
1245
1545
|
|
|
1246
1546
|
//#endregion
|
|
1247
1547
|
//#region packages/core/src/Decorators/Http/Header.ts
|
|
1548
|
+
/**
|
|
1549
|
+
* A decorator class for handling HTTP header parameters.
|
|
1550
|
+
*
|
|
1551
|
+
* This class extends the BaseDecorator and is used to register header parameters
|
|
1552
|
+
* with the MetadataResolver. It ensures that the metadata for the property is created
|
|
1553
|
+
* and adds the header information to the metadata.
|
|
1554
|
+
*
|
|
1555
|
+
* @extends {BaseDecorator<HeaderDecoratorOptions>}
|
|
1556
|
+
*/
|
|
1248
1557
|
var HeaderDecorator = class extends BaseDecorator {
|
|
1249
1558
|
/**
|
|
1250
1559
|
* Called when the decorator is created.
|
|
@@ -1262,12 +1571,31 @@ var HeaderDecorator = class extends BaseDecorator {
|
|
|
1262
1571
|
});
|
|
1263
1572
|
}
|
|
1264
1573
|
};
|
|
1574
|
+
/**
|
|
1575
|
+
* A decorator function for handling HTTP header parameters.
|
|
1576
|
+
*
|
|
1577
|
+
* This function creates a HeaderDecorator with the specified name and registers it.
|
|
1578
|
+
* It is used to annotate a parameter in a method to indicate that it should be
|
|
1579
|
+
* populated with the value of a specific HTTP header.
|
|
1580
|
+
*
|
|
1581
|
+
* @param {string} name - The name of the HTTP header to bind to the parameter.
|
|
1582
|
+
* @returns {Function} - A decorator function that registers the HeaderDecorator.
|
|
1583
|
+
*/
|
|
1265
1584
|
function Header(name) {
|
|
1266
1585
|
return createDecorator(HeaderDecorator, { name });
|
|
1267
1586
|
}
|
|
1268
1587
|
|
|
1269
1588
|
//#endregion
|
|
1270
1589
|
//#region packages/core/src/Decorators/Http/Headers.ts
|
|
1590
|
+
/**
|
|
1591
|
+
* This class is responsible for managing headers decorator.
|
|
1592
|
+
*
|
|
1593
|
+
* This class extends the BaseDecorator and is used to register headers parameters
|
|
1594
|
+
* with the MetadataResolver. It ensures that the metadata for the property is created
|
|
1595
|
+
* and adds the headers information to the metadata.
|
|
1596
|
+
*
|
|
1597
|
+
* @extends {BaseDecorator<{}>}
|
|
1598
|
+
*/
|
|
1271
1599
|
var HeadersDecorator = class extends BaseDecorator {
|
|
1272
1600
|
/**
|
|
1273
1601
|
* Called when the decorator is created.
|
|
@@ -1284,12 +1612,29 @@ var HeadersDecorator = class extends BaseDecorator {
|
|
|
1284
1612
|
});
|
|
1285
1613
|
}
|
|
1286
1614
|
};
|
|
1615
|
+
/**
|
|
1616
|
+
* A factory function for creating a HeadersDecorator.
|
|
1617
|
+
*
|
|
1618
|
+
* This function returns a decorator function that can be used to annotate
|
|
1619
|
+
* a method parameter with headers information.
|
|
1620
|
+
*
|
|
1621
|
+
* @return {Function} The decorator function.
|
|
1622
|
+
*/
|
|
1287
1623
|
function Headers$1() {
|
|
1288
1624
|
return createDecorator(HeadersDecorator, {});
|
|
1289
1625
|
}
|
|
1290
1626
|
|
|
1291
1627
|
//#endregion
|
|
1292
1628
|
//#region packages/core/src/Decorators/Http/Options.ts
|
|
1629
|
+
/**
|
|
1630
|
+
* A decorator class for handling HTTP OPTIONS requests.
|
|
1631
|
+
*
|
|
1632
|
+
* This class extends the BaseDecorator and is used to register OPTIONS routes
|
|
1633
|
+
* with the Router. It also resolves metadata for the route handler
|
|
1634
|
+
* using the MetadataResolver.
|
|
1635
|
+
*
|
|
1636
|
+
* @extends {BaseDecorator<OptionsDecoratorOptions>}
|
|
1637
|
+
*/
|
|
1293
1638
|
var OptionsDecorator = class extends BaseDecorator {
|
|
1294
1639
|
gRouter;
|
|
1295
1640
|
gRequestHandler;
|
|
@@ -1321,12 +1666,30 @@ var OptionsDecorator = class extends BaseDecorator {
|
|
|
1321
1666
|
__decorate([Inject(Router)], OptionsDecorator.prototype, "gRouter", void 0);
|
|
1322
1667
|
__decorate([Inject(RequestHandler)], OptionsDecorator.prototype, "gRequestHandler", void 0);
|
|
1323
1668
|
__decorate([Inject(MetadataResolver)], OptionsDecorator.prototype, "gMetadataResolver", void 0);
|
|
1669
|
+
/**
|
|
1670
|
+
* A factory function for creating an OptionsDecorator.
|
|
1671
|
+
*
|
|
1672
|
+
* This function returns a decorator function that can be used to annotate
|
|
1673
|
+
* a method with OPTIONS route information.
|
|
1674
|
+
*
|
|
1675
|
+
* @param {string} path - The path for the OPTIONS route.
|
|
1676
|
+
* @return {Function} The decorator function.
|
|
1677
|
+
*/
|
|
1324
1678
|
function Options(path) {
|
|
1325
1679
|
return createDecorator(OptionsDecorator, { path });
|
|
1326
1680
|
}
|
|
1327
1681
|
|
|
1328
1682
|
//#endregion
|
|
1329
1683
|
//#region packages/core/src/Decorators/Http/Param.ts
|
|
1684
|
+
/**
|
|
1685
|
+
* This class is responsible for managing parameter decorators.
|
|
1686
|
+
*
|
|
1687
|
+
* This class extends the BaseDecorator and is used to register parameter information
|
|
1688
|
+
* with the MetadataResolver. It ensures that the metadata for the property is created
|
|
1689
|
+
* and adds the parameter information to the metadata.
|
|
1690
|
+
*
|
|
1691
|
+
* @extends {BaseDecorator<ParamDecoratorOptions>}
|
|
1692
|
+
*/
|
|
1330
1693
|
var ParamDecorator = class extends BaseDecorator {
|
|
1331
1694
|
gMetadataResolver;
|
|
1332
1695
|
/**
|
|
@@ -1346,12 +1709,32 @@ var ParamDecorator = class extends BaseDecorator {
|
|
|
1346
1709
|
}
|
|
1347
1710
|
};
|
|
1348
1711
|
__decorate([Inject(MetadataResolver)], ParamDecorator.prototype, "gMetadataResolver", void 0);
|
|
1712
|
+
/**
|
|
1713
|
+
* A factory function for creating a ParamDecorator.
|
|
1714
|
+
*
|
|
1715
|
+
* This function returns a decorator function that can be used to annotate
|
|
1716
|
+
* a method parameter with parameter information.
|
|
1717
|
+
*
|
|
1718
|
+
* @param {string} name - The name of the parameter.
|
|
1719
|
+
* @param {Object} [opts] - Optional settings for the parameter.
|
|
1720
|
+
* @param {boolean} [opts.decode=false] - Whether to decode the parameter.
|
|
1721
|
+
* @return {Function} The decorator function.
|
|
1722
|
+
*/
|
|
1349
1723
|
function Param(name) {
|
|
1350
1724
|
return createDecorator(ParamDecorator, { name });
|
|
1351
1725
|
}
|
|
1352
1726
|
|
|
1353
1727
|
//#endregion
|
|
1354
1728
|
//#region packages/core/src/Decorators/Http/Patch.ts
|
|
1729
|
+
/**
|
|
1730
|
+
* A decorator class for handling HTTP PATCH requests.
|
|
1731
|
+
*
|
|
1732
|
+
* This class extends the BaseDecorator and is used to register PATCH routes
|
|
1733
|
+
* with the Router. It also resolves metadata for the route handler
|
|
1734
|
+
* using the MetadataResolver.
|
|
1735
|
+
*
|
|
1736
|
+
* @extends {BaseDecorator<PatchDecoratorOptions>}
|
|
1737
|
+
*/
|
|
1355
1738
|
var PatchDecorator = class extends BaseDecorator {
|
|
1356
1739
|
gRouter;
|
|
1357
1740
|
gRequestHandler;
|
|
@@ -1381,12 +1764,30 @@ var PatchDecorator = class extends BaseDecorator {
|
|
|
1381
1764
|
__decorate([Inject(Router)], PatchDecorator.prototype, "gRouter", void 0);
|
|
1382
1765
|
__decorate([Inject(RequestHandler)], PatchDecorator.prototype, "gRequestHandler", void 0);
|
|
1383
1766
|
__decorate([Inject(MetadataResolver)], PatchDecorator.prototype, "gMetadataResolver", void 0);
|
|
1767
|
+
/**
|
|
1768
|
+
* A factory function for creating a PatchDecorator.
|
|
1769
|
+
*
|
|
1770
|
+
* This function returns a decorator function that can be used to annotate
|
|
1771
|
+
* a method with PATCH route information.
|
|
1772
|
+
*
|
|
1773
|
+
* @param {string} path - The path for the PATCH route.
|
|
1774
|
+
* @return {Function} The decorator function.
|
|
1775
|
+
*/
|
|
1384
1776
|
function Patch(path) {
|
|
1385
1777
|
return createDecorator(PatchDecorator, { path });
|
|
1386
1778
|
}
|
|
1387
1779
|
|
|
1388
1780
|
//#endregion
|
|
1389
1781
|
//#region packages/core/src/Decorators/Http/Post.ts
|
|
1782
|
+
/**
|
|
1783
|
+
* A decorator class for handling HTTP POST requests.
|
|
1784
|
+
*
|
|
1785
|
+
* This class extends the BaseDecorator and is used to register POST routes
|
|
1786
|
+
* with the Router. It also resolves metadata for the route handler
|
|
1787
|
+
* using the MetadataResolver.
|
|
1788
|
+
*
|
|
1789
|
+
* @extends {BaseDecorator<PostDecoratorOptions>}
|
|
1790
|
+
*/
|
|
1390
1791
|
var PostDecorator = class extends BaseDecorator {
|
|
1391
1792
|
gRouter;
|
|
1392
1793
|
gMetadataResolver;
|
|
@@ -1418,12 +1819,30 @@ var PostDecorator = class extends BaseDecorator {
|
|
|
1418
1819
|
__decorate([Inject(Router)], PostDecorator.prototype, "gRouter", void 0);
|
|
1419
1820
|
__decorate([Inject(MetadataResolver)], PostDecorator.prototype, "gMetadataResolver", void 0);
|
|
1420
1821
|
__decorate([Inject(RequestHandler)], PostDecorator.prototype, "gRequestHandler", void 0);
|
|
1822
|
+
/**
|
|
1823
|
+
* A factory function for creating a PostDecorator.
|
|
1824
|
+
*
|
|
1825
|
+
* This function returns a decorator function that can be used to annotate
|
|
1826
|
+
* a method with POST route information.
|
|
1827
|
+
*
|
|
1828
|
+
* @param {string} path - The path for the POST route.
|
|
1829
|
+
* @return {Function} The decorator function.
|
|
1830
|
+
*/
|
|
1421
1831
|
function Post(path) {
|
|
1422
1832
|
return createDecorator(PostDecorator, { path });
|
|
1423
1833
|
}
|
|
1424
1834
|
|
|
1425
1835
|
//#endregion
|
|
1426
1836
|
//#region packages/core/src/Decorators/Http/Put.ts
|
|
1837
|
+
/**
|
|
1838
|
+
* A decorator class for handling HTTP PUT requests.
|
|
1839
|
+
*
|
|
1840
|
+
* This class extends the BaseDecorator and is used to register PUT routes
|
|
1841
|
+
* with the Router. It also resolves metadata for the route handler
|
|
1842
|
+
* using the MetadataResolver.
|
|
1843
|
+
*
|
|
1844
|
+
* @extends {BaseDecorator<PutDecoratorOptions>}
|
|
1845
|
+
*/
|
|
1427
1846
|
var PutDecorator = class extends BaseDecorator {
|
|
1428
1847
|
gRouter;
|
|
1429
1848
|
gRequestHandler;
|
|
@@ -1455,12 +1874,30 @@ var PutDecorator = class extends BaseDecorator {
|
|
|
1455
1874
|
__decorate([Inject(Router)], PutDecorator.prototype, "gRouter", void 0);
|
|
1456
1875
|
__decorate([Inject(RequestHandler)], PutDecorator.prototype, "gRequestHandler", void 0);
|
|
1457
1876
|
__decorate([Inject(MetadataResolver)], PutDecorator.prototype, "gMetadataResolver", void 0);
|
|
1877
|
+
/**
|
|
1878
|
+
* A factory function for creating a PutDecorator.
|
|
1879
|
+
*
|
|
1880
|
+
* This function returns a decorator function that can be used to annotate
|
|
1881
|
+
* a method with PUT route information.
|
|
1882
|
+
*
|
|
1883
|
+
* @param {string} path - The path for the PUT route.
|
|
1884
|
+
* @return {Function} The decorator function.
|
|
1885
|
+
*/
|
|
1458
1886
|
function Put(path) {
|
|
1459
1887
|
return createDecorator(PutDecorator, { path });
|
|
1460
1888
|
}
|
|
1461
1889
|
|
|
1462
1890
|
//#endregion
|
|
1463
1891
|
//#region packages/core/src/Decorators/Http/QueryParam.ts
|
|
1892
|
+
/**
|
|
1893
|
+
* This class is responsible for managing query parameter decorators.
|
|
1894
|
+
*
|
|
1895
|
+
* This class extends the BaseDecorator and is used to register query parameter information
|
|
1896
|
+
* with the MetadataResolver. It ensures that the metadata for the property is created
|
|
1897
|
+
* and adds the query parameter information to the metadata.
|
|
1898
|
+
*
|
|
1899
|
+
* @extends {BaseDecorator<QueryDecoratorOptions>}
|
|
1900
|
+
*/
|
|
1464
1901
|
var QueryParamDecorator = class extends BaseDecorator {
|
|
1465
1902
|
/**
|
|
1466
1903
|
* Called when the decorator is created.
|
|
@@ -1486,12 +1923,30 @@ var QueryParamDecorator = class extends BaseDecorator {
|
|
|
1486
1923
|
});
|
|
1487
1924
|
}
|
|
1488
1925
|
};
|
|
1926
|
+
/**
|
|
1927
|
+
* A factory function for creating a QueryDecorator.
|
|
1928
|
+
*
|
|
1929
|
+
* This function returns a decorator function that can be used to annotate
|
|
1930
|
+
* a method parameter with query parameter information.
|
|
1931
|
+
*
|
|
1932
|
+
* @param {QueryParamDecoratorOptions} options - The options for the decorator.
|
|
1933
|
+
* @return {Function} The decorator function.
|
|
1934
|
+
*/
|
|
1489
1935
|
function QueryParam(options) {
|
|
1490
1936
|
return createDecorator(QueryParamDecorator, options);
|
|
1491
1937
|
}
|
|
1492
1938
|
|
|
1493
1939
|
//#endregion
|
|
1494
1940
|
//#region packages/core/src/Decorators/Http/QueryParams.ts
|
|
1941
|
+
/**
|
|
1942
|
+
* This class is responsible for managing query parameters decorators.
|
|
1943
|
+
*
|
|
1944
|
+
* This class extends the BaseDecorator and is used to register query parameters information
|
|
1945
|
+
* with the MetadataResolver. It ensures that the metadata for the property is created
|
|
1946
|
+
* and adds the query parameters information to the metadata.
|
|
1947
|
+
*
|
|
1948
|
+
* @extends {BaseDecorator<QueryDecoratorOptions>}
|
|
1949
|
+
*/
|
|
1495
1950
|
var QueryParamsDecorator = class extends BaseDecorator {
|
|
1496
1951
|
/**
|
|
1497
1952
|
* Called when the decorator is created.
|
|
@@ -1517,12 +1972,30 @@ var QueryParamsDecorator = class extends BaseDecorator {
|
|
|
1517
1972
|
});
|
|
1518
1973
|
}
|
|
1519
1974
|
};
|
|
1975
|
+
/**
|
|
1976
|
+
* A factory function for creating a QueryParamsDecorator.
|
|
1977
|
+
*
|
|
1978
|
+
* This function returns a decorator function that can be used to annotate
|
|
1979
|
+
* a method parameter with query parameter information.
|
|
1980
|
+
*
|
|
1981
|
+
* @param {QueryParamsDecoratorOptions} options - The options for the decorator.
|
|
1982
|
+
* @return {Function} The decorator function.
|
|
1983
|
+
*/
|
|
1520
1984
|
function QueryParams(options) {
|
|
1521
1985
|
return createDecorator(QueryParamsDecorator, options);
|
|
1522
1986
|
}
|
|
1523
1987
|
|
|
1524
1988
|
//#endregion
|
|
1525
1989
|
//#region packages/core/src/Decorators/Http/Request.ts
|
|
1990
|
+
/**
|
|
1991
|
+
* This class is responsible for managing request decorators.
|
|
1992
|
+
*
|
|
1993
|
+
* This class extends the BaseDecorator and is used to register request information
|
|
1994
|
+
* with the MetadataResolver. It ensures that the metadata for the property is created
|
|
1995
|
+
* and adds the request information to the metadata.
|
|
1996
|
+
*
|
|
1997
|
+
* @extends {BaseDecorator<{}>}
|
|
1998
|
+
*/
|
|
1526
1999
|
var RequestDecorator = class extends BaseDecorator {
|
|
1527
2000
|
/**
|
|
1528
2001
|
* Called when the decorator is created.
|
|
@@ -1539,12 +2012,29 @@ var RequestDecorator = class extends BaseDecorator {
|
|
|
1539
2012
|
});
|
|
1540
2013
|
}
|
|
1541
2014
|
};
|
|
2015
|
+
/**
|
|
2016
|
+
* A factory function for creating a RequestDecorator.
|
|
2017
|
+
*
|
|
2018
|
+
* This function returns a decorator function that can be used to annotate
|
|
2019
|
+
* a method parameter with request information.
|
|
2020
|
+
*
|
|
2021
|
+
* @return {Function} The decorator function.
|
|
2022
|
+
*/
|
|
1542
2023
|
function Request() {
|
|
1543
2024
|
return createDecorator(RequestDecorator, {});
|
|
1544
2025
|
}
|
|
1545
2026
|
|
|
1546
2027
|
//#endregion
|
|
1547
2028
|
//#region packages/core/src/Decorators/Http/Response.ts
|
|
2029
|
+
/**
|
|
2030
|
+
* This class is responsible for managing response decorators.
|
|
2031
|
+
*
|
|
2032
|
+
* This class extends the BaseDecorator and is used to register response information
|
|
2033
|
+
* with the MetadataResolver. It ensures that the metadata for the property is created
|
|
2034
|
+
* and adds the response information to the metadata.
|
|
2035
|
+
*
|
|
2036
|
+
* @extends {BaseDecorator<{}>}
|
|
2037
|
+
*/
|
|
1548
2038
|
var ResponseDecorator = class extends BaseDecorator {
|
|
1549
2039
|
/**
|
|
1550
2040
|
* Called when the decorator is created.
|
|
@@ -1561,12 +2051,29 @@ var ResponseDecorator = class extends BaseDecorator {
|
|
|
1561
2051
|
});
|
|
1562
2052
|
}
|
|
1563
2053
|
};
|
|
2054
|
+
/**
|
|
2055
|
+
* A factory function for creating a ResponseDecorator.
|
|
2056
|
+
*
|
|
2057
|
+
* This function returns a decorator function that can be used to annotate
|
|
2058
|
+
* a method parameter with response information.
|
|
2059
|
+
*
|
|
2060
|
+
* @return {Function} The decorator function.
|
|
2061
|
+
*/
|
|
1564
2062
|
function Response$1() {
|
|
1565
2063
|
return createDecorator(ResponseDecorator, {});
|
|
1566
2064
|
}
|
|
1567
2065
|
|
|
1568
2066
|
//#endregion
|
|
1569
2067
|
//#region packages/core/src/Decorators/Http/Trace.ts
|
|
2068
|
+
/**
|
|
2069
|
+
* A decorator class for handling HTTP TRACE requests.
|
|
2070
|
+
*
|
|
2071
|
+
* This class extends the BaseDecorator and is used to register TRACE routes
|
|
2072
|
+
* with the Router. It also resolves metadata for the route handler
|
|
2073
|
+
* using the MetadataResolver.
|
|
2074
|
+
*
|
|
2075
|
+
* @extends {BaseDecorator<TraceDecoratorOptions>}
|
|
2076
|
+
*/
|
|
1570
2077
|
var TraceDecorator = class extends BaseDecorator {
|
|
1571
2078
|
gRouter;
|
|
1572
2079
|
gRequestHandler;
|
|
@@ -1598,12 +2105,25 @@ var TraceDecorator = class extends BaseDecorator {
|
|
|
1598
2105
|
__decorate([Inject(Router)], TraceDecorator.prototype, "gRouter", void 0);
|
|
1599
2106
|
__decorate([Inject(RequestHandler)], TraceDecorator.prototype, "gRequestHandler", void 0);
|
|
1600
2107
|
__decorate([Inject(MetadataResolver)], TraceDecorator.prototype, "gMetadataResolver", void 0);
|
|
2108
|
+
/**
|
|
2109
|
+
* A factory function for creating a TraceDecorator.
|
|
2110
|
+
*
|
|
2111
|
+
* This function returns a decorator function that can be used to annotate
|
|
2112
|
+
* a method with TRACE route information.
|
|
2113
|
+
*
|
|
2114
|
+
* @param {string} path - The path for the TRACE route.
|
|
2115
|
+
* @return {Function} The decorator function.
|
|
2116
|
+
*/
|
|
1601
2117
|
function Trace(path) {
|
|
1602
2118
|
return createDecorator(TraceDecorator, { path });
|
|
1603
2119
|
}
|
|
1604
2120
|
|
|
1605
2121
|
//#endregion
|
|
1606
2122
|
//#region packages/core/src/Decorators/Http/SetHeader.ts
|
|
2123
|
+
/**
|
|
2124
|
+
* A decorator that sets a header on the response.
|
|
2125
|
+
* @extends {BaseDecorator<SetHeaderDecoratorOptions>}
|
|
2126
|
+
*/
|
|
1607
2127
|
var SetHeaderDecorator = class extends BaseDecorator {
|
|
1608
2128
|
/**
|
|
1609
2129
|
* Called when the decorator is created.
|
|
@@ -1620,6 +2140,12 @@ var SetHeaderDecorator = class extends BaseDecorator {
|
|
|
1620
2140
|
} });
|
|
1621
2141
|
}
|
|
1622
2142
|
};
|
|
2143
|
+
/**
|
|
2144
|
+
* Creates a SetHeader decorator.
|
|
2145
|
+
* @param {string} key - The header key.
|
|
2146
|
+
* @param {string} value - The header value.
|
|
2147
|
+
* @returns {Function} The decorator function.
|
|
2148
|
+
*/
|
|
1623
2149
|
function SetHeader(key, value) {
|
|
1624
2150
|
return createDecorator(SetHeaderDecorator, {
|
|
1625
2151
|
key,
|
|
@@ -1629,6 +2155,13 @@ function SetHeader(key, value) {
|
|
|
1629
2155
|
|
|
1630
2156
|
//#endregion
|
|
1631
2157
|
//#region packages/core/src/Decorators/Http/Status.ts
|
|
2158
|
+
/**
|
|
2159
|
+
|
|
2160
|
+
* A decorator that sets a status on the response.
|
|
2161
|
+
|
|
2162
|
+
* @extends {BaseDecorator<StatusDecoratorOptions>}
|
|
2163
|
+
|
|
2164
|
+
*/
|
|
1632
2165
|
var StatusDecorator = class extends BaseDecorator {
|
|
1633
2166
|
/**
|
|
1634
2167
|
|
|
@@ -1645,6 +2178,15 @@ var StatusDecorator = class extends BaseDecorator {
|
|
|
1645
2178
|
method.actions.push({ handler: () => ({ status: this.options.code }) });
|
|
1646
2179
|
}
|
|
1647
2180
|
};
|
|
2181
|
+
/**
|
|
2182
|
+
|
|
2183
|
+
* Creates a Status decorator.
|
|
2184
|
+
|
|
2185
|
+
* @param {number} code - The status value.
|
|
2186
|
+
|
|
2187
|
+
* @returns {Function} The decorator function.
|
|
2188
|
+
|
|
2189
|
+
*/
|
|
1648
2190
|
function Status(code) {
|
|
1649
2191
|
return createDecorator(StatusDecorator, { code });
|
|
1650
2192
|
}
|
|
@@ -1674,6 +2216,17 @@ var RedirectDecorator = class extends BaseDecorator {
|
|
|
1674
2216
|
} });
|
|
1675
2217
|
}
|
|
1676
2218
|
};
|
|
2219
|
+
/**
|
|
2220
|
+
|
|
2221
|
+
* Creates a Redirect decorator.
|
|
2222
|
+
|
|
2223
|
+
* @param {string} location - The location header value.
|
|
2224
|
+
|
|
2225
|
+
* @param {number} [code=301] - The status code.
|
|
2226
|
+
|
|
2227
|
+
* @returns {Function} The decorator function.
|
|
2228
|
+
|
|
2229
|
+
*/
|
|
1677
2230
|
function Redirect(location, code = 301) {
|
|
1678
2231
|
return createDecorator(RedirectDecorator, {
|
|
1679
2232
|
location,
|
|
@@ -1683,6 +2236,28 @@ function Redirect(location, code = 301) {
|
|
|
1683
2236
|
|
|
1684
2237
|
//#endregion
|
|
1685
2238
|
//#region packages/core/src/Decorators/Http/Middleware.ts
|
|
2239
|
+
/**
|
|
2240
|
+
* Decorator that applies middleware to a class or method
|
|
2241
|
+
* @param middleware - The middleware class to apply
|
|
2242
|
+
* @param opts - Optional configuration parameters
|
|
2243
|
+
* @param opts.type - The type of middleware ('before' or 'after')
|
|
2244
|
+
* @param opts.priority - Priority order for middleware execution (default: 999)
|
|
2245
|
+
* @returns A decorator function that can be applied to classes or methods
|
|
2246
|
+
*
|
|
2247
|
+
* @example
|
|
2248
|
+
* ```typescript
|
|
2249
|
+
* @Middleware(AuthMiddleware)
|
|
2250
|
+
* class UserController {
|
|
2251
|
+
* // ...
|
|
2252
|
+
* }
|
|
2253
|
+
*
|
|
2254
|
+
* // Or on a specific method:
|
|
2255
|
+
* @Middleware(ValidationMiddleware, { type: 'before', priority: 1 })
|
|
2256
|
+
* public async createUser() {
|
|
2257
|
+
* // ...
|
|
2258
|
+
* }
|
|
2259
|
+
* ```
|
|
2260
|
+
*/
|
|
1686
2261
|
function Middleware(middleware, opts) {
|
|
1687
2262
|
return function internalDecorator(target, propertyName) {
|
|
1688
2263
|
const ctx = propertyName ? target : target.prototype;
|
|
@@ -1697,6 +2272,12 @@ function Middleware(middleware, opts) {
|
|
|
1697
2272
|
|
|
1698
2273
|
//#endregion
|
|
1699
2274
|
//#region packages/core/src/Decorators/Http/MultipartFormData.ts
|
|
2275
|
+
/**
|
|
2276
|
+
* @class MultipartFormDataDecorator
|
|
2277
|
+
* @extends BaseDecorator<MultipartFormDataOptions>
|
|
2278
|
+
*
|
|
2279
|
+
* A decorator class that handles the metadata for HTTP request bodies.
|
|
2280
|
+
*/
|
|
1700
2281
|
var MultipartFormDataDecorator = class extends BaseDecorator {
|
|
1701
2282
|
/**
|
|
1702
2283
|
* @method created
|
|
@@ -1712,12 +2293,35 @@ var MultipartFormDataDecorator = class extends BaseDecorator {
|
|
|
1712
2293
|
});
|
|
1713
2294
|
}
|
|
1714
2295
|
};
|
|
2296
|
+
/**
|
|
2297
|
+
* Decorator function that marks a parameter as multipart/form-data request body.
|
|
2298
|
+
* This decorator will automatically parse incoming multipart form data
|
|
2299
|
+
*
|
|
2300
|
+
* @decorator
|
|
2301
|
+
* @returns {Function} A decorator function that can be applied to method parameters
|
|
2302
|
+
*
|
|
2303
|
+
* @example
|
|
2304
|
+
* class UserController {
|
|
2305
|
+
* uploadFile(@MultipartFormData() formData: MyData) {
|
|
2306
|
+
* // Handle multipart form data
|
|
2307
|
+
* }
|
|
2308
|
+
* }
|
|
2309
|
+
*/
|
|
1715
2310
|
function MultipartFormData() {
|
|
1716
2311
|
return createDecorator(MultipartFormDataDecorator, {});
|
|
1717
2312
|
}
|
|
1718
2313
|
|
|
1719
2314
|
//#endregion
|
|
1720
2315
|
//#region packages/core/src/Decorators/Http/Session.ts
|
|
2316
|
+
/**
|
|
2317
|
+
* This class is responsible for managing session decorators.
|
|
2318
|
+
*
|
|
2319
|
+
* This class extends the BaseDecorator and is used to register session information
|
|
2320
|
+
* with the MetadataResolver. It ensures that the metadata for the property is created
|
|
2321
|
+
* and adds the session information to the metadata.
|
|
2322
|
+
*
|
|
2323
|
+
* @extends {BaseDecorator<{}>}
|
|
2324
|
+
*/
|
|
1721
2325
|
var SessionDecorator = class extends BaseDecorator {
|
|
1722
2326
|
gRuntimeConfig;
|
|
1723
2327
|
/**
|
|
@@ -1741,12 +2345,23 @@ var SessionDecorator = class extends BaseDecorator {
|
|
|
1741
2345
|
}
|
|
1742
2346
|
};
|
|
1743
2347
|
__decorate([Inject(RuntimeConfig)], SessionDecorator.prototype, "gRuntimeConfig", void 0);
|
|
2348
|
+
/**
|
|
2349
|
+
* A factory function for creating a SessionDecorator.
|
|
2350
|
+
*
|
|
2351
|
+
* This function returns a decorator function that can be used to annotate
|
|
2352
|
+
* a method parameter with session information.
|
|
2353
|
+
*
|
|
2354
|
+
* @return {Function} The decorator function.
|
|
2355
|
+
*/
|
|
1744
2356
|
function Session() {
|
|
1745
2357
|
return createDecorator(SessionDecorator, {});
|
|
1746
2358
|
}
|
|
1747
2359
|
|
|
1748
2360
|
//#endregion
|
|
1749
2361
|
//#region packages/core/src/Decorators/Hooks/Listen.ts
|
|
2362
|
+
/**
|
|
2363
|
+
* This class is responsible for managing cache decorator.
|
|
2364
|
+
*/
|
|
1750
2365
|
var ListenDecorator = class extends BaseDecorator {
|
|
1751
2366
|
gHooksService;
|
|
1752
2367
|
fHook;
|
|
@@ -1765,12 +2380,22 @@ var ListenDecorator = class extends BaseDecorator {
|
|
|
1765
2380
|
}
|
|
1766
2381
|
};
|
|
1767
2382
|
__decorate([Inject(HooksService)], ListenDecorator.prototype, "gHooksService", void 0);
|
|
2383
|
+
/**
|
|
2384
|
+
* This decorator stores metadata about hook listeners. It can be later used along with function
|
|
2385
|
+
* applyEventListeners() to automatically register all listeners.
|
|
2386
|
+
*
|
|
2387
|
+
* @param hookType hook to listen for
|
|
2388
|
+
* @return decorator function
|
|
2389
|
+
*/
|
|
1768
2390
|
function Listen(hookType) {
|
|
1769
2391
|
return createDecorator(ListenDecorator, { hookType });
|
|
1770
2392
|
}
|
|
1771
2393
|
|
|
1772
2394
|
//#endregion
|
|
1773
2395
|
//#region packages/core/src/Services/Plugins/BasePlugin.ts
|
|
2396
|
+
/**
|
|
2397
|
+
* Represents a Plugin.
|
|
2398
|
+
*/
|
|
1774
2399
|
var BasePlugin = class {
|
|
1775
2400
|
/**
|
|
1776
2401
|
* The name of the plugin.
|
|
@@ -1786,10 +2411,17 @@ var BasePlugin = class {
|
|
|
1786
2411
|
|
|
1787
2412
|
//#endregion
|
|
1788
2413
|
//#region packages/core/src/Services/Middleware/BaseMiddleware.ts
|
|
2414
|
+
/**
|
|
2415
|
+
* BaseMiddleware class that serves as a base for all middleware implementations.
|
|
2416
|
+
*/
|
|
1789
2417
|
var BaseMiddleware = class {};
|
|
1790
2418
|
|
|
1791
2419
|
//#endregion
|
|
1792
2420
|
//#region packages/core/src/Errors/Http/ForbiddenError.ts
|
|
2421
|
+
/**
|
|
2422
|
+
* Represents a Forbidden error (HTTP 403).
|
|
2423
|
+
* @extends {HttpError}
|
|
2424
|
+
*/
|
|
1793
2425
|
var ForbiddenError = class ForbiddenError extends HttpError {
|
|
1794
2426
|
/**
|
|
1795
2427
|
* The name of the error.
|
|
@@ -1809,6 +2441,10 @@ var ForbiddenError = class ForbiddenError extends HttpError {
|
|
|
1809
2441
|
|
|
1810
2442
|
//#endregion
|
|
1811
2443
|
//#region packages/core/src/Errors/Http/MethodNotAllowedError.ts
|
|
2444
|
+
/**
|
|
2445
|
+
* Represents a Method Not Allowed error (HTTP 405).
|
|
2446
|
+
* @extends {HttpError}
|
|
2447
|
+
*/
|
|
1812
2448
|
var MethodNotAllowedError = class MethodNotAllowedError extends HttpError {
|
|
1813
2449
|
/**
|
|
1814
2450
|
* The name of the error.
|
|
@@ -1828,6 +2464,10 @@ var MethodNotAllowedError = class MethodNotAllowedError extends HttpError {
|
|
|
1828
2464
|
|
|
1829
2465
|
//#endregion
|
|
1830
2466
|
//#region packages/core/src/Errors/Http/NotAcceptableError.ts
|
|
2467
|
+
/**
|
|
2468
|
+
* Represents a Not Acceptable error (HTTP 406).
|
|
2469
|
+
* @extends {HttpError}
|
|
2470
|
+
*/
|
|
1831
2471
|
var NotAcceptableError = class NotAcceptableError extends HttpError {
|
|
1832
2472
|
/**
|
|
1833
2473
|
* The name of the error.
|
|
@@ -1847,6 +2487,10 @@ var NotAcceptableError = class NotAcceptableError extends HttpError {
|
|
|
1847
2487
|
|
|
1848
2488
|
//#endregion
|
|
1849
2489
|
//#region packages/core/src/Errors/Http/NotFoundError.ts
|
|
2490
|
+
/**
|
|
2491
|
+
* Represents a Not Found error (HTTP 404).
|
|
2492
|
+
* @extends {HttpError}
|
|
2493
|
+
*/
|
|
1850
2494
|
var NotFoundError = class NotFoundError extends HttpError {
|
|
1851
2495
|
/**
|
|
1852
2496
|
* The name of the error.
|
|
@@ -1866,6 +2510,10 @@ var NotFoundError = class NotFoundError extends HttpError {
|
|
|
1866
2510
|
|
|
1867
2511
|
//#endregion
|
|
1868
2512
|
//#region packages/core/src/Errors/Http/UnauthorizedError.ts
|
|
2513
|
+
/**
|
|
2514
|
+
* Represents an Unauthorized error (HTTP 401).
|
|
2515
|
+
* @extends {HttpError}
|
|
2516
|
+
*/
|
|
1869
2517
|
var UnauthorizedError = class UnauthorizedError extends HttpError {
|
|
1870
2518
|
/**
|
|
1871
2519
|
* The name of the error.
|
|
@@ -1951,4 +2599,4 @@ let HTTPStatus = /* @__PURE__ */ function(HTTPStatus$1) {
|
|
|
1951
2599
|
}({});
|
|
1952
2600
|
|
|
1953
2601
|
//#endregion
|
|
1954
|
-
export { App, BadRequestError, BaseMiddleware, BasePlugin, Body, Connect, Controller, Delete, ForbiddenError, Get, HTTPStatus, Head, Header, Headers$1 as Headers, HooksService, HttpError, HttpServer, InternalServerError, Listen, MetadataResolver, MethodNotAllowedError, Middleware, MultipartFormData, NotAcceptableError, NotFoundError, Options, Param, Patch, Post, Put, QueryParam, QueryParams, Redirect, Request, Response$1 as Response, Session, SetHeader, Status, Trace, UnauthorizedError, createApp, createMetadataCtx, createMetadataMethod, defineConfig, initializeMetadata, initializeMetadataMethod, loadVercubeConfig };
|
|
2602
|
+
export { App, BadRequestError, BaseMiddleware, BasePlugin, Body, Connect, Controller, Delete, ErrorHandlerProvider, ForbiddenError, Get, GlobalMiddlewareRegistry, HTTPStatus, Head, Header, Headers$1 as Headers, HooksService, HttpError, HttpServer, InternalServerError, Listen, MetadataResolver, MethodNotAllowedError, Middleware, MultipartFormData, NotAcceptableError, NotFoundError, Options, Param, Patch, Post, Put, QueryParam, QueryParams, Redirect, Request, Response$1 as Response, Session, SetHeader, Status, Trace, UnauthorizedError, createApp, createMetadataCtx, createMetadataMethod, defineConfig, initializeMetadata, initializeMetadataMethod, loadVercubeConfig };
|