@vercube/core 0.0.1 → 0.0.2-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Types/HttpTypes.d.ts +1 -1
- package/dist/index.cjs +654 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +653 -2
- 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,6 +500,15 @@ 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;
|
|
@@ -558,6 +655,15 @@ const mime = { getType(ext) {
|
|
|
558
655
|
|
|
559
656
|
//#endregion
|
|
560
657
|
//#region packages/core/src/Services/Router/StaticRequestHandler.ts
|
|
658
|
+
/**
|
|
659
|
+
* Handles serving static files over HTTP
|
|
660
|
+
*
|
|
661
|
+
* The StaticRequestHandler is responsible for:
|
|
662
|
+
* - Serving static files from configured directories
|
|
663
|
+
* - Setting appropriate content types and headers
|
|
664
|
+
* - Handling caching and ETags
|
|
665
|
+
* - Processing GET requests for static assets
|
|
666
|
+
*/
|
|
561
667
|
var StaticRequestHandler = class {
|
|
562
668
|
/**
|
|
563
669
|
* The options for the static server
|
|
@@ -623,6 +729,14 @@ var StaticRequestHandler = class {
|
|
|
623
729
|
|
|
624
730
|
//#endregion
|
|
625
731
|
//#region packages/core/src/Services/HttpServer/HttpServer.ts
|
|
732
|
+
/**
|
|
733
|
+
* HTTP server implementation for handling incoming web requests
|
|
734
|
+
*
|
|
735
|
+
* This class is responsible for:
|
|
736
|
+
* - Initializing and managing the HTTP server
|
|
737
|
+
* - Routing incoming requests to appropriate handlers
|
|
738
|
+
* - Processing HTTP responses
|
|
739
|
+
*/
|
|
626
740
|
var HttpServer = class {
|
|
627
741
|
/**
|
|
628
742
|
* Router service for resolving routes
|
|
@@ -708,6 +822,9 @@ __decorate([Inject(StaticRequestHandler)], HttpServer.prototype, "gStaticRequest
|
|
|
708
822
|
|
|
709
823
|
//#endregion
|
|
710
824
|
//#region packages/core/src/Common/App.ts
|
|
825
|
+
/**
|
|
826
|
+
* Represents the main application class.
|
|
827
|
+
*/
|
|
711
828
|
var App = class {
|
|
712
829
|
gRouter;
|
|
713
830
|
gPluginsRegistry;
|
|
@@ -784,6 +901,13 @@ __decorate([Inject(StaticRequestHandler)], App.prototype, "gStaticRequestHandler
|
|
|
784
901
|
|
|
785
902
|
//#endregion
|
|
786
903
|
//#region packages/logger/dist/Providers/index.mjs
|
|
904
|
+
/**
|
|
905
|
+
* Abstract base class for implementing log provider.
|
|
906
|
+
* Providers are responsible for processing and outputting log messages to various destinations.
|
|
907
|
+
* Each appender can be initialized with custom options and handles message processing according to its implementation.
|
|
908
|
+
*
|
|
909
|
+
* @template T - The type of options used to initialize the appender
|
|
910
|
+
*/
|
|
787
911
|
var LoggerProvider = class {};
|
|
788
912
|
const isColorAllowed = () => !process.env.NO_COLOR;
|
|
789
913
|
const colorIfAllowed = (colorFn) => {
|
|
@@ -806,6 +930,9 @@ const LOG_LEVEL_COLORS = {
|
|
|
806
930
|
warn: colors.yellow,
|
|
807
931
|
error: colors.red
|
|
808
932
|
};
|
|
933
|
+
/**
|
|
934
|
+
* ConsoleProvider class for logging messages to the console.
|
|
935
|
+
*/
|
|
809
936
|
var ConsoleProvider = class extends LoggerProvider {
|
|
810
937
|
/**
|
|
811
938
|
* Initializes the appender with the provided options.
|
|
@@ -825,10 +952,23 @@ var ConsoleProvider = class extends LoggerProvider {
|
|
|
825
952
|
|
|
826
953
|
//#endregion
|
|
827
954
|
//#region packages/core/src/Services/Validation/ValidationProvider.ts
|
|
955
|
+
/**
|
|
956
|
+
* Abstract class representing a validation provider
|
|
957
|
+
* Provides a common interface for different validation implementations
|
|
958
|
+
*
|
|
959
|
+
* @abstract
|
|
960
|
+
* @class ValidationProvider
|
|
961
|
+
*/
|
|
828
962
|
var ValidationProvider = class {};
|
|
829
963
|
|
|
830
964
|
//#endregion
|
|
831
965
|
//#region packages/core/src/Services/Validation/StandardSchemaValidationProvider.ts
|
|
966
|
+
/**
|
|
967
|
+
* StandardSchemaValidationProvider implements validation using StandardSchema schema validation
|
|
968
|
+
* @see https://github.com/standard-schema/standard-schema
|
|
969
|
+
* @class
|
|
970
|
+
* @implements {ValidationProvider}
|
|
971
|
+
*/
|
|
832
972
|
var StandardSchemaValidationProvider = class {
|
|
833
973
|
/**
|
|
834
974
|
* Validates data against a schema
|
|
@@ -843,6 +983,10 @@ var StandardSchemaValidationProvider = class {
|
|
|
843
983
|
|
|
844
984
|
//#endregion
|
|
845
985
|
//#region packages/core/src/Services/Config/RuntimeConfig.ts
|
|
986
|
+
/**
|
|
987
|
+
* RuntimeConfig class manages the runtime configuration for the Vercube application.
|
|
988
|
+
* This class provides a centralized way to access and modify runtime configuration settings.
|
|
989
|
+
*/
|
|
846
990
|
var RuntimeConfig = class {
|
|
847
991
|
/**
|
|
848
992
|
* Private field to store the runtime configuration object.
|
|
@@ -867,6 +1011,10 @@ var RuntimeConfig = class {
|
|
|
867
1011
|
|
|
868
1012
|
//#endregion
|
|
869
1013
|
//#region packages/core/src/Errors/Http/InternalServerError.ts
|
|
1014
|
+
/**
|
|
1015
|
+
* Represents an Internal Server error (HTTP 500).
|
|
1016
|
+
* @extends {HttpError}
|
|
1017
|
+
*/
|
|
870
1018
|
var InternalServerError = class InternalServerError extends HttpError {
|
|
871
1019
|
/**
|
|
872
1020
|
* The name of the error.
|
|
@@ -886,6 +1034,11 @@ var InternalServerError = class InternalServerError extends HttpError {
|
|
|
886
1034
|
|
|
887
1035
|
//#endregion
|
|
888
1036
|
//#region packages/core/src/Services/ErrorHandler/DefaultErrorHandlerProvider.ts
|
|
1037
|
+
/**
|
|
1038
|
+
* Default error handler provider
|
|
1039
|
+
*
|
|
1040
|
+
* @class DefaultErrorHandlerProvider
|
|
1041
|
+
*/
|
|
889
1042
|
var DefaultErrorHandlerProvider = class extends ErrorHandlerProvider {
|
|
890
1043
|
gLogger;
|
|
891
1044
|
/**
|
|
@@ -906,6 +1059,11 @@ __decorate([Inject(Logger)], DefaultErrorHandlerProvider.prototype, "gLogger", v
|
|
|
906
1059
|
|
|
907
1060
|
//#endregion
|
|
908
1061
|
//#region packages/core/src/Common/Container.ts
|
|
1062
|
+
/**
|
|
1063
|
+
* Creates and configures a new dependency injection container for the application.
|
|
1064
|
+
*
|
|
1065
|
+
* @returns {Container} A configured dependency injection container.
|
|
1066
|
+
*/
|
|
909
1067
|
function createContainer(config) {
|
|
910
1068
|
const container = new Container();
|
|
911
1069
|
container.bindInstance(Container, container);
|
|
@@ -933,6 +1091,10 @@ function createContainer(config) {
|
|
|
933
1091
|
|
|
934
1092
|
//#endregion
|
|
935
1093
|
//#region packages/core/src/Utils/InternalUtils.ts
|
|
1094
|
+
/**
|
|
1095
|
+
* Generate random hash
|
|
1096
|
+
* @returns string
|
|
1097
|
+
*/
|
|
936
1098
|
function generateRandomHash() {
|
|
937
1099
|
const hashByPerformance = Math.floor(Date.now() * 1e3).toString(16);
|
|
938
1100
|
const hashByMath = () => (Math.floor(Math.random() * 16777215) | 1048576).toString(16);
|
|
@@ -941,6 +1103,10 @@ function generateRandomHash() {
|
|
|
941
1103
|
|
|
942
1104
|
//#endregion
|
|
943
1105
|
//#region packages/core/src/Config/DefaultConfig.ts
|
|
1106
|
+
/**
|
|
1107
|
+
* Default configuration for the Vercube application.
|
|
1108
|
+
* This configuration serves as the base settings and can be overridden by user configuration.
|
|
1109
|
+
*/
|
|
944
1110
|
const defaultConfig = {
|
|
945
1111
|
logLevel: "debug",
|
|
946
1112
|
production: false,
|
|
@@ -971,6 +1137,11 @@ const defaultConfig = {
|
|
|
971
1137
|
|
|
972
1138
|
//#endregion
|
|
973
1139
|
//#region packages/core/src/Config/Loader.ts
|
|
1140
|
+
/**
|
|
1141
|
+
* Loads the configuration object for the application
|
|
1142
|
+
* @param {ConfigTypes.Config} overrides - The configuration object to load
|
|
1143
|
+
* @returns {ConfigTypes.Config} The loaded configuration object
|
|
1144
|
+
*/
|
|
974
1145
|
async function loadVercubeConfig(overrides) {
|
|
975
1146
|
const config = await loadConfig({
|
|
976
1147
|
name: "vercube",
|
|
@@ -984,6 +1155,11 @@ async function loadVercubeConfig(overrides) {
|
|
|
984
1155
|
|
|
985
1156
|
//#endregion
|
|
986
1157
|
//#region packages/core/src/Common/CreateApp.ts
|
|
1158
|
+
/**
|
|
1159
|
+
* Creates and initializes an instance of the App.
|
|
1160
|
+
*
|
|
1161
|
+
* @returns {Promise<App>} A promise that resolves to an instance of the App.
|
|
1162
|
+
*/
|
|
987
1163
|
async function createApp(cfg) {
|
|
988
1164
|
const config = await loadVercubeConfig(cfg);
|
|
989
1165
|
const container = createContainer(config);
|
|
@@ -997,12 +1173,26 @@ async function createApp(cfg) {
|
|
|
997
1173
|
|
|
998
1174
|
//#endregion
|
|
999
1175
|
//#region packages/core/src/Config/Config.ts
|
|
1176
|
+
/**
|
|
1177
|
+
* Defines a configuration object for the application
|
|
1178
|
+
* @param {ConfigTypes.Config} config - The configuration object to validate
|
|
1179
|
+
* @returns {ConfigTypes.Config} The validated configuration object
|
|
1180
|
+
*/
|
|
1000
1181
|
function defineConfig(config) {
|
|
1001
1182
|
return config;
|
|
1002
1183
|
}
|
|
1003
1184
|
|
|
1004
1185
|
//#endregion
|
|
1005
1186
|
//#region packages/core/src/Middleware/ValidationMiddleware.ts
|
|
1187
|
+
/**
|
|
1188
|
+
* Middleware for validating request data against a schema
|
|
1189
|
+
* @class ValidationMiddleware
|
|
1190
|
+
* @implements {BaseMiddleware}
|
|
1191
|
+
* @description Validates incoming request data against a provided schema
|
|
1192
|
+
* @example
|
|
1193
|
+
* const middleware = new ValidationMiddleware();
|
|
1194
|
+
* await middleware.use(event, { schema: myValidationSchema });
|
|
1195
|
+
*/
|
|
1006
1196
|
var ValidationMiddleware = class {
|
|
1007
1197
|
gValidationProvider;
|
|
1008
1198
|
/**
|
|
@@ -1029,6 +1219,10 @@ __decorate([InjectOptional(ValidationProvider)], ValidationMiddleware.prototype,
|
|
|
1029
1219
|
|
|
1030
1220
|
//#endregion
|
|
1031
1221
|
//#region packages/core/src/Utils/Utils.ts
|
|
1222
|
+
/**
|
|
1223
|
+
* Creates a new metadata context.
|
|
1224
|
+
* @returns {MetadataTypes.Ctx} The new metadata context.
|
|
1225
|
+
*/
|
|
1032
1226
|
function createMetadataCtx() {
|
|
1033
1227
|
return {
|
|
1034
1228
|
__controller: { path: "" },
|
|
@@ -1036,6 +1230,10 @@ function createMetadataCtx() {
|
|
|
1036
1230
|
__methods: {}
|
|
1037
1231
|
};
|
|
1038
1232
|
}
|
|
1233
|
+
/**
|
|
1234
|
+
* Creates a new metadata method.
|
|
1235
|
+
* @returns {MetadataTypes.Method} The new metadata method.
|
|
1236
|
+
*/
|
|
1039
1237
|
function createMetadataMethod() {
|
|
1040
1238
|
return {
|
|
1041
1239
|
req: null,
|
|
@@ -1045,10 +1243,19 @@ function createMetadataMethod() {
|
|
|
1045
1243
|
actions: []
|
|
1046
1244
|
};
|
|
1047
1245
|
}
|
|
1246
|
+
/**
|
|
1247
|
+
* Initializes the metadata for a given target and property name.
|
|
1248
|
+
* @param {any} target - The target to initialize metadata for.
|
|
1249
|
+
* @param {string} propertyName - The name of the property to initialize metadata for.
|
|
1250
|
+
*/
|
|
1048
1251
|
function initializeMetadataMethod(target, propertyName) {
|
|
1049
1252
|
if (!target.__metadata.__methods[propertyName]) target.__metadata.__methods[propertyName] = createMetadataMethod();
|
|
1050
1253
|
return target.__metadata.__methods[propertyName];
|
|
1051
1254
|
}
|
|
1255
|
+
/**
|
|
1256
|
+
* Initializes the metadata for a given target.
|
|
1257
|
+
* @param {any} target - The target to initialize metadata for.
|
|
1258
|
+
*/
|
|
1052
1259
|
function initializeMetadata(target) {
|
|
1053
1260
|
if (!target.__metadata) target.__metadata = createMetadataCtx();
|
|
1054
1261
|
if (!target.__metadata.__methods) target.__metadata.__methods = {};
|
|
@@ -1058,6 +1265,12 @@ function initializeMetadata(target) {
|
|
|
1058
1265
|
|
|
1059
1266
|
//#endregion
|
|
1060
1267
|
//#region packages/core/src/Decorators/Http/Body.ts
|
|
1268
|
+
/**
|
|
1269
|
+
* @class BodyDecorator
|
|
1270
|
+
* @extends BaseDecorator<BodyDecoratorOptions>
|
|
1271
|
+
*
|
|
1272
|
+
* A decorator class that handles the metadata for HTTP request bodies.
|
|
1273
|
+
*/
|
|
1061
1274
|
var BodyDecorator = class extends BaseDecorator {
|
|
1062
1275
|
/**
|
|
1063
1276
|
* @method created
|
|
@@ -1081,12 +1294,30 @@ var BodyDecorator = class extends BaseDecorator {
|
|
|
1081
1294
|
});
|
|
1082
1295
|
}
|
|
1083
1296
|
};
|
|
1297
|
+
/**
|
|
1298
|
+
* @function Body
|
|
1299
|
+
* @returns {Function} A decorator function that registers the BodyDecorator.
|
|
1300
|
+
*
|
|
1301
|
+
* This function creates and returns a decorator that can be used to annotate
|
|
1302
|
+
* a parameter in a method to indicate that it should be populated with the
|
|
1303
|
+
* body of an HTTP request. The decorator uses the BodyDecorator class to
|
|
1304
|
+
* handle the metadata associated with the parameter.
|
|
1305
|
+
*/
|
|
1084
1306
|
function Body(options) {
|
|
1085
1307
|
return createDecorator(BodyDecorator, options);
|
|
1086
1308
|
}
|
|
1087
1309
|
|
|
1088
1310
|
//#endregion
|
|
1089
1311
|
//#region packages/core/src/Decorators/Http/Connect.ts
|
|
1312
|
+
/**
|
|
1313
|
+
* A decorator class for handling HTTP CONNECT requests.
|
|
1314
|
+
*
|
|
1315
|
+
* This class extends the BaseDecorator and is used to register CONNECT routes
|
|
1316
|
+
* with the Router. It also resolves metadata for the route handler
|
|
1317
|
+
* using the MetadataResolver.
|
|
1318
|
+
*
|
|
1319
|
+
* @extends {BaseDecorator<ConnectDecoratorOptions>}
|
|
1320
|
+
*/
|
|
1090
1321
|
var ConnectDecorator = class extends BaseDecorator {
|
|
1091
1322
|
gRouter;
|
|
1092
1323
|
gRequestHandler;
|
|
@@ -1116,12 +1347,30 @@ var ConnectDecorator = class extends BaseDecorator {
|
|
|
1116
1347
|
__decorate([Inject(Router)], ConnectDecorator.prototype, "gRouter", void 0);
|
|
1117
1348
|
__decorate([Inject(RequestHandler)], ConnectDecorator.prototype, "gRequestHandler", void 0);
|
|
1118
1349
|
__decorate([Inject(MetadataResolver)], ConnectDecorator.prototype, "gMetadataResolver", void 0);
|
|
1350
|
+
/**
|
|
1351
|
+
* A factory function for creating a ConnectDecorator.
|
|
1352
|
+
*
|
|
1353
|
+
* This function returns a decorator function that can be used to annotate
|
|
1354
|
+
* a method with CONNECT route information.
|
|
1355
|
+
*
|
|
1356
|
+
* @param {string} path - The path for the CONNECT route.
|
|
1357
|
+
* @return {Function} The decorator function.
|
|
1358
|
+
*/
|
|
1119
1359
|
function Connect(path) {
|
|
1120
1360
|
return createDecorator(ConnectDecorator, { path });
|
|
1121
1361
|
}
|
|
1122
1362
|
|
|
1123
1363
|
//#endregion
|
|
1124
1364
|
//#region packages/core/src/Decorators/Http/Controller.ts
|
|
1365
|
+
/**
|
|
1366
|
+
* A factory function for creating a Controller decorator.
|
|
1367
|
+
*
|
|
1368
|
+
* This function returns a decorator function that can be used to annotate
|
|
1369
|
+
* a class with controller metadata, including the base path for the controller.
|
|
1370
|
+
*
|
|
1371
|
+
* @param {string} path - The base path for the controller.
|
|
1372
|
+
* @return {Function} The decorator function.
|
|
1373
|
+
*/
|
|
1125
1374
|
function Controller(path) {
|
|
1126
1375
|
return function internalDecorator(target) {
|
|
1127
1376
|
const meta = initializeMetadata(target.prototype);
|
|
@@ -1134,6 +1383,15 @@ function Controller(path) {
|
|
|
1134
1383
|
|
|
1135
1384
|
//#endregion
|
|
1136
1385
|
//#region packages/core/src/Decorators/Http/Delete.ts
|
|
1386
|
+
/**
|
|
1387
|
+
* A decorator class for handling HTTP DELETE requests.
|
|
1388
|
+
*
|
|
1389
|
+
* This class extends the BaseDecorator and is used to register DELETE routes
|
|
1390
|
+
* with the Router. It also resolves metadata for the route handler
|
|
1391
|
+
* using the MetadataResolver.
|
|
1392
|
+
*
|
|
1393
|
+
* @extends {BaseDecorator<DeleteDecoratorOptions>}
|
|
1394
|
+
*/
|
|
1137
1395
|
var DeleteDecorator = class extends BaseDecorator {
|
|
1138
1396
|
gRouter;
|
|
1139
1397
|
gRequestHandler;
|
|
@@ -1165,12 +1423,30 @@ var DeleteDecorator = class extends BaseDecorator {
|
|
|
1165
1423
|
__decorate([Inject(Router)], DeleteDecorator.prototype, "gRouter", void 0);
|
|
1166
1424
|
__decorate([Inject(RequestHandler)], DeleteDecorator.prototype, "gRequestHandler", void 0);
|
|
1167
1425
|
__decorate([Inject(MetadataResolver)], DeleteDecorator.prototype, "gMetadataResolver", void 0);
|
|
1426
|
+
/**
|
|
1427
|
+
* A factory function for creating a DeleteDecorator.
|
|
1428
|
+
*
|
|
1429
|
+
* This function returns a decorator function that can be used to annotate
|
|
1430
|
+
* a method with DELETE route information.
|
|
1431
|
+
*
|
|
1432
|
+
* @param {string} path - The path for the DELETE route.
|
|
1433
|
+
* @return {Function} The decorator function.
|
|
1434
|
+
*/
|
|
1168
1435
|
function Delete(path) {
|
|
1169
1436
|
return createDecorator(DeleteDecorator, { path });
|
|
1170
1437
|
}
|
|
1171
1438
|
|
|
1172
1439
|
//#endregion
|
|
1173
1440
|
//#region packages/core/src/Decorators/Http/Get.ts
|
|
1441
|
+
/**
|
|
1442
|
+
* A decorator class for handling HTTP GET requests.
|
|
1443
|
+
*
|
|
1444
|
+
* This class extends the BaseDecorator and is used to register GET routes
|
|
1445
|
+
* with the Router. It also resolves metadata for the route handler
|
|
1446
|
+
* using the MetadataResolver.
|
|
1447
|
+
*
|
|
1448
|
+
* @extends {BaseDecorator<GetDecoratorOptions>}
|
|
1449
|
+
*/
|
|
1174
1450
|
var GetDecorator = class extends BaseDecorator {
|
|
1175
1451
|
gRouter;
|
|
1176
1452
|
gRequestHandler;
|
|
@@ -1202,12 +1478,30 @@ var GetDecorator = class extends BaseDecorator {
|
|
|
1202
1478
|
__decorate([Inject(Router)], GetDecorator.prototype, "gRouter", void 0);
|
|
1203
1479
|
__decorate([Inject(RequestHandler)], GetDecorator.prototype, "gRequestHandler", void 0);
|
|
1204
1480
|
__decorate([Inject(MetadataResolver)], GetDecorator.prototype, "gMetadataResolver", void 0);
|
|
1481
|
+
/**
|
|
1482
|
+
* A decorator function for handling HTTP GET requests.
|
|
1483
|
+
*
|
|
1484
|
+
* This function creates an instance of the GetDecorator class and registers
|
|
1485
|
+
* the GET route with the specified path.
|
|
1486
|
+
*
|
|
1487
|
+
* @param {string} path - The path for the GET route.
|
|
1488
|
+
* @returns {Function} - The decorator function.
|
|
1489
|
+
*/
|
|
1205
1490
|
function Get(path) {
|
|
1206
1491
|
return createDecorator(GetDecorator, { path });
|
|
1207
1492
|
}
|
|
1208
1493
|
|
|
1209
1494
|
//#endregion
|
|
1210
1495
|
//#region packages/core/src/Decorators/Http/Head.ts
|
|
1496
|
+
/**
|
|
1497
|
+
* A decorator class for handling HTTP HEAD requests.
|
|
1498
|
+
*
|
|
1499
|
+
* This class extends the BaseDecorator and is used to register HEAD routes
|
|
1500
|
+
* with the Router. It also resolves metadata for the route handler
|
|
1501
|
+
* using the MetadataResolver.
|
|
1502
|
+
*
|
|
1503
|
+
* @extends {BaseDecorator<HeadDecoratorOptions>}
|
|
1504
|
+
*/
|
|
1211
1505
|
var HeadDecorator = class extends BaseDecorator {
|
|
1212
1506
|
gRouter;
|
|
1213
1507
|
gRequestHandler;
|
|
@@ -1239,12 +1533,30 @@ var HeadDecorator = class extends BaseDecorator {
|
|
|
1239
1533
|
__decorate([Inject(Router)], HeadDecorator.prototype, "gRouter", void 0);
|
|
1240
1534
|
__decorate([Inject(RequestHandler)], HeadDecorator.prototype, "gRequestHandler", void 0);
|
|
1241
1535
|
__decorate([Inject(MetadataResolver)], HeadDecorator.prototype, "gMetadataResolver", void 0);
|
|
1536
|
+
/**
|
|
1537
|
+
* A factory function for creating a HeadDecorator.
|
|
1538
|
+
*
|
|
1539
|
+
* This function returns a decorator function that can be used to annotate
|
|
1540
|
+
* a method with HEAD route information.
|
|
1541
|
+
*
|
|
1542
|
+
* @param {string} path - The path for the HEAD route.
|
|
1543
|
+
* @return {Function} The decorator function.
|
|
1544
|
+
*/
|
|
1242
1545
|
function Head(path) {
|
|
1243
1546
|
return createDecorator(HeadDecorator, { path });
|
|
1244
1547
|
}
|
|
1245
1548
|
|
|
1246
1549
|
//#endregion
|
|
1247
1550
|
//#region packages/core/src/Decorators/Http/Header.ts
|
|
1551
|
+
/**
|
|
1552
|
+
* A decorator class for handling HTTP header parameters.
|
|
1553
|
+
*
|
|
1554
|
+
* This class extends the BaseDecorator and is used to register header parameters
|
|
1555
|
+
* with the MetadataResolver. It ensures that the metadata for the property is created
|
|
1556
|
+
* and adds the header information to the metadata.
|
|
1557
|
+
*
|
|
1558
|
+
* @extends {BaseDecorator<HeaderDecoratorOptions>}
|
|
1559
|
+
*/
|
|
1248
1560
|
var HeaderDecorator = class extends BaseDecorator {
|
|
1249
1561
|
/**
|
|
1250
1562
|
* Called when the decorator is created.
|
|
@@ -1262,12 +1574,31 @@ var HeaderDecorator = class extends BaseDecorator {
|
|
|
1262
1574
|
});
|
|
1263
1575
|
}
|
|
1264
1576
|
};
|
|
1577
|
+
/**
|
|
1578
|
+
* A decorator function for handling HTTP header parameters.
|
|
1579
|
+
*
|
|
1580
|
+
* This function creates a HeaderDecorator with the specified name and registers it.
|
|
1581
|
+
* It is used to annotate a parameter in a method to indicate that it should be
|
|
1582
|
+
* populated with the value of a specific HTTP header.
|
|
1583
|
+
*
|
|
1584
|
+
* @param {string} name - The name of the HTTP header to bind to the parameter.
|
|
1585
|
+
* @returns {Function} - A decorator function that registers the HeaderDecorator.
|
|
1586
|
+
*/
|
|
1265
1587
|
function Header(name) {
|
|
1266
1588
|
return createDecorator(HeaderDecorator, { name });
|
|
1267
1589
|
}
|
|
1268
1590
|
|
|
1269
1591
|
//#endregion
|
|
1270
1592
|
//#region packages/core/src/Decorators/Http/Headers.ts
|
|
1593
|
+
/**
|
|
1594
|
+
* This class is responsible for managing headers decorator.
|
|
1595
|
+
*
|
|
1596
|
+
* This class extends the BaseDecorator and is used to register headers parameters
|
|
1597
|
+
* with the MetadataResolver. It ensures that the metadata for the property is created
|
|
1598
|
+
* and adds the headers information to the metadata.
|
|
1599
|
+
*
|
|
1600
|
+
* @extends {BaseDecorator<{}>}
|
|
1601
|
+
*/
|
|
1271
1602
|
var HeadersDecorator = class extends BaseDecorator {
|
|
1272
1603
|
/**
|
|
1273
1604
|
* Called when the decorator is created.
|
|
@@ -1284,12 +1615,29 @@ var HeadersDecorator = class extends BaseDecorator {
|
|
|
1284
1615
|
});
|
|
1285
1616
|
}
|
|
1286
1617
|
};
|
|
1618
|
+
/**
|
|
1619
|
+
* A factory function for creating a HeadersDecorator.
|
|
1620
|
+
*
|
|
1621
|
+
* This function returns a decorator function that can be used to annotate
|
|
1622
|
+
* a method parameter with headers information.
|
|
1623
|
+
*
|
|
1624
|
+
* @return {Function} The decorator function.
|
|
1625
|
+
*/
|
|
1287
1626
|
function Headers$1() {
|
|
1288
1627
|
return createDecorator(HeadersDecorator, {});
|
|
1289
1628
|
}
|
|
1290
1629
|
|
|
1291
1630
|
//#endregion
|
|
1292
1631
|
//#region packages/core/src/Decorators/Http/Options.ts
|
|
1632
|
+
/**
|
|
1633
|
+
* A decorator class for handling HTTP OPTIONS requests.
|
|
1634
|
+
*
|
|
1635
|
+
* This class extends the BaseDecorator and is used to register OPTIONS routes
|
|
1636
|
+
* with the Router. It also resolves metadata for the route handler
|
|
1637
|
+
* using the MetadataResolver.
|
|
1638
|
+
*
|
|
1639
|
+
* @extends {BaseDecorator<OptionsDecoratorOptions>}
|
|
1640
|
+
*/
|
|
1293
1641
|
var OptionsDecorator = class extends BaseDecorator {
|
|
1294
1642
|
gRouter;
|
|
1295
1643
|
gRequestHandler;
|
|
@@ -1321,12 +1669,30 @@ var OptionsDecorator = class extends BaseDecorator {
|
|
|
1321
1669
|
__decorate([Inject(Router)], OptionsDecorator.prototype, "gRouter", void 0);
|
|
1322
1670
|
__decorate([Inject(RequestHandler)], OptionsDecorator.prototype, "gRequestHandler", void 0);
|
|
1323
1671
|
__decorate([Inject(MetadataResolver)], OptionsDecorator.prototype, "gMetadataResolver", void 0);
|
|
1672
|
+
/**
|
|
1673
|
+
* A factory function for creating an OptionsDecorator.
|
|
1674
|
+
*
|
|
1675
|
+
* This function returns a decorator function that can be used to annotate
|
|
1676
|
+
* a method with OPTIONS route information.
|
|
1677
|
+
*
|
|
1678
|
+
* @param {string} path - The path for the OPTIONS route.
|
|
1679
|
+
* @return {Function} The decorator function.
|
|
1680
|
+
*/
|
|
1324
1681
|
function Options(path) {
|
|
1325
1682
|
return createDecorator(OptionsDecorator, { path });
|
|
1326
1683
|
}
|
|
1327
1684
|
|
|
1328
1685
|
//#endregion
|
|
1329
1686
|
//#region packages/core/src/Decorators/Http/Param.ts
|
|
1687
|
+
/**
|
|
1688
|
+
* This class is responsible for managing parameter decorators.
|
|
1689
|
+
*
|
|
1690
|
+
* This class extends the BaseDecorator and is used to register parameter information
|
|
1691
|
+
* with the MetadataResolver. It ensures that the metadata for the property is created
|
|
1692
|
+
* and adds the parameter information to the metadata.
|
|
1693
|
+
*
|
|
1694
|
+
* @extends {BaseDecorator<ParamDecoratorOptions>}
|
|
1695
|
+
*/
|
|
1330
1696
|
var ParamDecorator = class extends BaseDecorator {
|
|
1331
1697
|
gMetadataResolver;
|
|
1332
1698
|
/**
|
|
@@ -1346,12 +1712,32 @@ var ParamDecorator = class extends BaseDecorator {
|
|
|
1346
1712
|
}
|
|
1347
1713
|
};
|
|
1348
1714
|
__decorate([Inject(MetadataResolver)], ParamDecorator.prototype, "gMetadataResolver", void 0);
|
|
1715
|
+
/**
|
|
1716
|
+
* A factory function for creating a ParamDecorator.
|
|
1717
|
+
*
|
|
1718
|
+
* This function returns a decorator function that can be used to annotate
|
|
1719
|
+
* a method parameter with parameter information.
|
|
1720
|
+
*
|
|
1721
|
+
* @param {string} name - The name of the parameter.
|
|
1722
|
+
* @param {Object} [opts] - Optional settings for the parameter.
|
|
1723
|
+
* @param {boolean} [opts.decode=false] - Whether to decode the parameter.
|
|
1724
|
+
* @return {Function} The decorator function.
|
|
1725
|
+
*/
|
|
1349
1726
|
function Param(name) {
|
|
1350
1727
|
return createDecorator(ParamDecorator, { name });
|
|
1351
1728
|
}
|
|
1352
1729
|
|
|
1353
1730
|
//#endregion
|
|
1354
1731
|
//#region packages/core/src/Decorators/Http/Patch.ts
|
|
1732
|
+
/**
|
|
1733
|
+
* A decorator class for handling HTTP PATCH requests.
|
|
1734
|
+
*
|
|
1735
|
+
* This class extends the BaseDecorator and is used to register PATCH routes
|
|
1736
|
+
* with the Router. It also resolves metadata for the route handler
|
|
1737
|
+
* using the MetadataResolver.
|
|
1738
|
+
*
|
|
1739
|
+
* @extends {BaseDecorator<PatchDecoratorOptions>}
|
|
1740
|
+
*/
|
|
1355
1741
|
var PatchDecorator = class extends BaseDecorator {
|
|
1356
1742
|
gRouter;
|
|
1357
1743
|
gRequestHandler;
|
|
@@ -1381,12 +1767,30 @@ var PatchDecorator = class extends BaseDecorator {
|
|
|
1381
1767
|
__decorate([Inject(Router)], PatchDecorator.prototype, "gRouter", void 0);
|
|
1382
1768
|
__decorate([Inject(RequestHandler)], PatchDecorator.prototype, "gRequestHandler", void 0);
|
|
1383
1769
|
__decorate([Inject(MetadataResolver)], PatchDecorator.prototype, "gMetadataResolver", void 0);
|
|
1770
|
+
/**
|
|
1771
|
+
* A factory function for creating a PatchDecorator.
|
|
1772
|
+
*
|
|
1773
|
+
* This function returns a decorator function that can be used to annotate
|
|
1774
|
+
* a method with PATCH route information.
|
|
1775
|
+
*
|
|
1776
|
+
* @param {string} path - The path for the PATCH route.
|
|
1777
|
+
* @return {Function} The decorator function.
|
|
1778
|
+
*/
|
|
1384
1779
|
function Patch(path) {
|
|
1385
1780
|
return createDecorator(PatchDecorator, { path });
|
|
1386
1781
|
}
|
|
1387
1782
|
|
|
1388
1783
|
//#endregion
|
|
1389
1784
|
//#region packages/core/src/Decorators/Http/Post.ts
|
|
1785
|
+
/**
|
|
1786
|
+
* A decorator class for handling HTTP POST requests.
|
|
1787
|
+
*
|
|
1788
|
+
* This class extends the BaseDecorator and is used to register POST routes
|
|
1789
|
+
* with the Router. It also resolves metadata for the route handler
|
|
1790
|
+
* using the MetadataResolver.
|
|
1791
|
+
*
|
|
1792
|
+
* @extends {BaseDecorator<PostDecoratorOptions>}
|
|
1793
|
+
*/
|
|
1390
1794
|
var PostDecorator = class extends BaseDecorator {
|
|
1391
1795
|
gRouter;
|
|
1392
1796
|
gMetadataResolver;
|
|
@@ -1418,12 +1822,30 @@ var PostDecorator = class extends BaseDecorator {
|
|
|
1418
1822
|
__decorate([Inject(Router)], PostDecorator.prototype, "gRouter", void 0);
|
|
1419
1823
|
__decorate([Inject(MetadataResolver)], PostDecorator.prototype, "gMetadataResolver", void 0);
|
|
1420
1824
|
__decorate([Inject(RequestHandler)], PostDecorator.prototype, "gRequestHandler", void 0);
|
|
1825
|
+
/**
|
|
1826
|
+
* A factory function for creating a PostDecorator.
|
|
1827
|
+
*
|
|
1828
|
+
* This function returns a decorator function that can be used to annotate
|
|
1829
|
+
* a method with POST route information.
|
|
1830
|
+
*
|
|
1831
|
+
* @param {string} path - The path for the POST route.
|
|
1832
|
+
* @return {Function} The decorator function.
|
|
1833
|
+
*/
|
|
1421
1834
|
function Post(path) {
|
|
1422
1835
|
return createDecorator(PostDecorator, { path });
|
|
1423
1836
|
}
|
|
1424
1837
|
|
|
1425
1838
|
//#endregion
|
|
1426
1839
|
//#region packages/core/src/Decorators/Http/Put.ts
|
|
1840
|
+
/**
|
|
1841
|
+
* A decorator class for handling HTTP PUT requests.
|
|
1842
|
+
*
|
|
1843
|
+
* This class extends the BaseDecorator and is used to register PUT routes
|
|
1844
|
+
* with the Router. It also resolves metadata for the route handler
|
|
1845
|
+
* using the MetadataResolver.
|
|
1846
|
+
*
|
|
1847
|
+
* @extends {BaseDecorator<PutDecoratorOptions>}
|
|
1848
|
+
*/
|
|
1427
1849
|
var PutDecorator = class extends BaseDecorator {
|
|
1428
1850
|
gRouter;
|
|
1429
1851
|
gRequestHandler;
|
|
@@ -1455,12 +1877,30 @@ var PutDecorator = class extends BaseDecorator {
|
|
|
1455
1877
|
__decorate([Inject(Router)], PutDecorator.prototype, "gRouter", void 0);
|
|
1456
1878
|
__decorate([Inject(RequestHandler)], PutDecorator.prototype, "gRequestHandler", void 0);
|
|
1457
1879
|
__decorate([Inject(MetadataResolver)], PutDecorator.prototype, "gMetadataResolver", void 0);
|
|
1880
|
+
/**
|
|
1881
|
+
* A factory function for creating a PutDecorator.
|
|
1882
|
+
*
|
|
1883
|
+
* This function returns a decorator function that can be used to annotate
|
|
1884
|
+
* a method with PUT route information.
|
|
1885
|
+
*
|
|
1886
|
+
* @param {string} path - The path for the PUT route.
|
|
1887
|
+
* @return {Function} The decorator function.
|
|
1888
|
+
*/
|
|
1458
1889
|
function Put(path) {
|
|
1459
1890
|
return createDecorator(PutDecorator, { path });
|
|
1460
1891
|
}
|
|
1461
1892
|
|
|
1462
1893
|
//#endregion
|
|
1463
1894
|
//#region packages/core/src/Decorators/Http/QueryParam.ts
|
|
1895
|
+
/**
|
|
1896
|
+
* This class is responsible for managing query parameter decorators.
|
|
1897
|
+
*
|
|
1898
|
+
* This class extends the BaseDecorator and is used to register query parameter information
|
|
1899
|
+
* with the MetadataResolver. It ensures that the metadata for the property is created
|
|
1900
|
+
* and adds the query parameter information to the metadata.
|
|
1901
|
+
*
|
|
1902
|
+
* @extends {BaseDecorator<QueryDecoratorOptions>}
|
|
1903
|
+
*/
|
|
1464
1904
|
var QueryParamDecorator = class extends BaseDecorator {
|
|
1465
1905
|
/**
|
|
1466
1906
|
* Called when the decorator is created.
|
|
@@ -1486,12 +1926,30 @@ var QueryParamDecorator = class extends BaseDecorator {
|
|
|
1486
1926
|
});
|
|
1487
1927
|
}
|
|
1488
1928
|
};
|
|
1929
|
+
/**
|
|
1930
|
+
* A factory function for creating a QueryDecorator.
|
|
1931
|
+
*
|
|
1932
|
+
* This function returns a decorator function that can be used to annotate
|
|
1933
|
+
* a method parameter with query parameter information.
|
|
1934
|
+
*
|
|
1935
|
+
* @param {QueryParamDecoratorOptions} options - The options for the decorator.
|
|
1936
|
+
* @return {Function} The decorator function.
|
|
1937
|
+
*/
|
|
1489
1938
|
function QueryParam(options) {
|
|
1490
1939
|
return createDecorator(QueryParamDecorator, options);
|
|
1491
1940
|
}
|
|
1492
1941
|
|
|
1493
1942
|
//#endregion
|
|
1494
1943
|
//#region packages/core/src/Decorators/Http/QueryParams.ts
|
|
1944
|
+
/**
|
|
1945
|
+
* This class is responsible for managing query parameters decorators.
|
|
1946
|
+
*
|
|
1947
|
+
* This class extends the BaseDecorator and is used to register query parameters information
|
|
1948
|
+
* with the MetadataResolver. It ensures that the metadata for the property is created
|
|
1949
|
+
* and adds the query parameters information to the metadata.
|
|
1950
|
+
*
|
|
1951
|
+
* @extends {BaseDecorator<QueryDecoratorOptions>}
|
|
1952
|
+
*/
|
|
1495
1953
|
var QueryParamsDecorator = class extends BaseDecorator {
|
|
1496
1954
|
/**
|
|
1497
1955
|
* Called when the decorator is created.
|
|
@@ -1517,12 +1975,30 @@ var QueryParamsDecorator = class extends BaseDecorator {
|
|
|
1517
1975
|
});
|
|
1518
1976
|
}
|
|
1519
1977
|
};
|
|
1978
|
+
/**
|
|
1979
|
+
* A factory function for creating a QueryParamsDecorator.
|
|
1980
|
+
*
|
|
1981
|
+
* This function returns a decorator function that can be used to annotate
|
|
1982
|
+
* a method parameter with query parameter information.
|
|
1983
|
+
*
|
|
1984
|
+
* @param {QueryParamsDecoratorOptions} options - The options for the decorator.
|
|
1985
|
+
* @return {Function} The decorator function.
|
|
1986
|
+
*/
|
|
1520
1987
|
function QueryParams(options) {
|
|
1521
1988
|
return createDecorator(QueryParamsDecorator, options);
|
|
1522
1989
|
}
|
|
1523
1990
|
|
|
1524
1991
|
//#endregion
|
|
1525
1992
|
//#region packages/core/src/Decorators/Http/Request.ts
|
|
1993
|
+
/**
|
|
1994
|
+
* This class is responsible for managing request decorators.
|
|
1995
|
+
*
|
|
1996
|
+
* This class extends the BaseDecorator and is used to register request information
|
|
1997
|
+
* with the MetadataResolver. It ensures that the metadata for the property is created
|
|
1998
|
+
* and adds the request information to the metadata.
|
|
1999
|
+
*
|
|
2000
|
+
* @extends {BaseDecorator<{}>}
|
|
2001
|
+
*/
|
|
1526
2002
|
var RequestDecorator = class extends BaseDecorator {
|
|
1527
2003
|
/**
|
|
1528
2004
|
* Called when the decorator is created.
|
|
@@ -1539,12 +2015,29 @@ var RequestDecorator = class extends BaseDecorator {
|
|
|
1539
2015
|
});
|
|
1540
2016
|
}
|
|
1541
2017
|
};
|
|
2018
|
+
/**
|
|
2019
|
+
* A factory function for creating a RequestDecorator.
|
|
2020
|
+
*
|
|
2021
|
+
* This function returns a decorator function that can be used to annotate
|
|
2022
|
+
* a method parameter with request information.
|
|
2023
|
+
*
|
|
2024
|
+
* @return {Function} The decorator function.
|
|
2025
|
+
*/
|
|
1542
2026
|
function Request() {
|
|
1543
2027
|
return createDecorator(RequestDecorator, {});
|
|
1544
2028
|
}
|
|
1545
2029
|
|
|
1546
2030
|
//#endregion
|
|
1547
2031
|
//#region packages/core/src/Decorators/Http/Response.ts
|
|
2032
|
+
/**
|
|
2033
|
+
* This class is responsible for managing response decorators.
|
|
2034
|
+
*
|
|
2035
|
+
* This class extends the BaseDecorator and is used to register response information
|
|
2036
|
+
* with the MetadataResolver. It ensures that the metadata for the property is created
|
|
2037
|
+
* and adds the response information to the metadata.
|
|
2038
|
+
*
|
|
2039
|
+
* @extends {BaseDecorator<{}>}
|
|
2040
|
+
*/
|
|
1548
2041
|
var ResponseDecorator = class extends BaseDecorator {
|
|
1549
2042
|
/**
|
|
1550
2043
|
* Called when the decorator is created.
|
|
@@ -1561,12 +2054,29 @@ var ResponseDecorator = class extends BaseDecorator {
|
|
|
1561
2054
|
});
|
|
1562
2055
|
}
|
|
1563
2056
|
};
|
|
2057
|
+
/**
|
|
2058
|
+
* A factory function for creating a ResponseDecorator.
|
|
2059
|
+
*
|
|
2060
|
+
* This function returns a decorator function that can be used to annotate
|
|
2061
|
+
* a method parameter with response information.
|
|
2062
|
+
*
|
|
2063
|
+
* @return {Function} The decorator function.
|
|
2064
|
+
*/
|
|
1564
2065
|
function Response$1() {
|
|
1565
2066
|
return createDecorator(ResponseDecorator, {});
|
|
1566
2067
|
}
|
|
1567
2068
|
|
|
1568
2069
|
//#endregion
|
|
1569
2070
|
//#region packages/core/src/Decorators/Http/Trace.ts
|
|
2071
|
+
/**
|
|
2072
|
+
* A decorator class for handling HTTP TRACE requests.
|
|
2073
|
+
*
|
|
2074
|
+
* This class extends the BaseDecorator and is used to register TRACE routes
|
|
2075
|
+
* with the Router. It also resolves metadata for the route handler
|
|
2076
|
+
* using the MetadataResolver.
|
|
2077
|
+
*
|
|
2078
|
+
* @extends {BaseDecorator<TraceDecoratorOptions>}
|
|
2079
|
+
*/
|
|
1570
2080
|
var TraceDecorator = class extends BaseDecorator {
|
|
1571
2081
|
gRouter;
|
|
1572
2082
|
gRequestHandler;
|
|
@@ -1598,12 +2108,25 @@ var TraceDecorator = class extends BaseDecorator {
|
|
|
1598
2108
|
__decorate([Inject(Router)], TraceDecorator.prototype, "gRouter", void 0);
|
|
1599
2109
|
__decorate([Inject(RequestHandler)], TraceDecorator.prototype, "gRequestHandler", void 0);
|
|
1600
2110
|
__decorate([Inject(MetadataResolver)], TraceDecorator.prototype, "gMetadataResolver", void 0);
|
|
2111
|
+
/**
|
|
2112
|
+
* A factory function for creating a TraceDecorator.
|
|
2113
|
+
*
|
|
2114
|
+
* This function returns a decorator function that can be used to annotate
|
|
2115
|
+
* a method with TRACE route information.
|
|
2116
|
+
*
|
|
2117
|
+
* @param {string} path - The path for the TRACE route.
|
|
2118
|
+
* @return {Function} The decorator function.
|
|
2119
|
+
*/
|
|
1601
2120
|
function Trace(path) {
|
|
1602
2121
|
return createDecorator(TraceDecorator, { path });
|
|
1603
2122
|
}
|
|
1604
2123
|
|
|
1605
2124
|
//#endregion
|
|
1606
2125
|
//#region packages/core/src/Decorators/Http/SetHeader.ts
|
|
2126
|
+
/**
|
|
2127
|
+
* A decorator that sets a header on the response.
|
|
2128
|
+
* @extends {BaseDecorator<SetHeaderDecoratorOptions>}
|
|
2129
|
+
*/
|
|
1607
2130
|
var SetHeaderDecorator = class extends BaseDecorator {
|
|
1608
2131
|
/**
|
|
1609
2132
|
* Called when the decorator is created.
|
|
@@ -1620,6 +2143,12 @@ var SetHeaderDecorator = class extends BaseDecorator {
|
|
|
1620
2143
|
} });
|
|
1621
2144
|
}
|
|
1622
2145
|
};
|
|
2146
|
+
/**
|
|
2147
|
+
* Creates a SetHeader decorator.
|
|
2148
|
+
* @param {string} key - The header key.
|
|
2149
|
+
* @param {string} value - The header value.
|
|
2150
|
+
* @returns {Function} The decorator function.
|
|
2151
|
+
*/
|
|
1623
2152
|
function SetHeader(key, value) {
|
|
1624
2153
|
return createDecorator(SetHeaderDecorator, {
|
|
1625
2154
|
key,
|
|
@@ -1629,6 +2158,13 @@ function SetHeader(key, value) {
|
|
|
1629
2158
|
|
|
1630
2159
|
//#endregion
|
|
1631
2160
|
//#region packages/core/src/Decorators/Http/Status.ts
|
|
2161
|
+
/**
|
|
2162
|
+
|
|
2163
|
+
* A decorator that sets a status on the response.
|
|
2164
|
+
|
|
2165
|
+
* @extends {BaseDecorator<StatusDecoratorOptions>}
|
|
2166
|
+
|
|
2167
|
+
*/
|
|
1632
2168
|
var StatusDecorator = class extends BaseDecorator {
|
|
1633
2169
|
/**
|
|
1634
2170
|
|
|
@@ -1645,6 +2181,15 @@ var StatusDecorator = class extends BaseDecorator {
|
|
|
1645
2181
|
method.actions.push({ handler: () => ({ status: this.options.code }) });
|
|
1646
2182
|
}
|
|
1647
2183
|
};
|
|
2184
|
+
/**
|
|
2185
|
+
|
|
2186
|
+
* Creates a Status decorator.
|
|
2187
|
+
|
|
2188
|
+
* @param {number} code - The status value.
|
|
2189
|
+
|
|
2190
|
+
* @returns {Function} The decorator function.
|
|
2191
|
+
|
|
2192
|
+
*/
|
|
1648
2193
|
function Status(code) {
|
|
1649
2194
|
return createDecorator(StatusDecorator, { code });
|
|
1650
2195
|
}
|
|
@@ -1674,6 +2219,17 @@ var RedirectDecorator = class extends BaseDecorator {
|
|
|
1674
2219
|
} });
|
|
1675
2220
|
}
|
|
1676
2221
|
};
|
|
2222
|
+
/**
|
|
2223
|
+
|
|
2224
|
+
* Creates a Redirect decorator.
|
|
2225
|
+
|
|
2226
|
+
* @param {string} location - The location header value.
|
|
2227
|
+
|
|
2228
|
+
* @param {number} [code=301] - The status code.
|
|
2229
|
+
|
|
2230
|
+
* @returns {Function} The decorator function.
|
|
2231
|
+
|
|
2232
|
+
*/
|
|
1677
2233
|
function Redirect(location, code = 301) {
|
|
1678
2234
|
return createDecorator(RedirectDecorator, {
|
|
1679
2235
|
location,
|
|
@@ -1683,6 +2239,28 @@ function Redirect(location, code = 301) {
|
|
|
1683
2239
|
|
|
1684
2240
|
//#endregion
|
|
1685
2241
|
//#region packages/core/src/Decorators/Http/Middleware.ts
|
|
2242
|
+
/**
|
|
2243
|
+
* Decorator that applies middleware to a class or method
|
|
2244
|
+
* @param middleware - The middleware class to apply
|
|
2245
|
+
* @param opts - Optional configuration parameters
|
|
2246
|
+
* @param opts.type - The type of middleware ('before' or 'after')
|
|
2247
|
+
* @param opts.priority - Priority order for middleware execution (default: 999)
|
|
2248
|
+
* @returns A decorator function that can be applied to classes or methods
|
|
2249
|
+
*
|
|
2250
|
+
* @example
|
|
2251
|
+
* ```typescript
|
|
2252
|
+
* @Middleware(AuthMiddleware)
|
|
2253
|
+
* class UserController {
|
|
2254
|
+
* // ...
|
|
2255
|
+
* }
|
|
2256
|
+
*
|
|
2257
|
+
* // Or on a specific method:
|
|
2258
|
+
* @Middleware(ValidationMiddleware, { type: 'before', priority: 1 })
|
|
2259
|
+
* public async createUser() {
|
|
2260
|
+
* // ...
|
|
2261
|
+
* }
|
|
2262
|
+
* ```
|
|
2263
|
+
*/
|
|
1686
2264
|
function Middleware(middleware, opts) {
|
|
1687
2265
|
return function internalDecorator(target, propertyName) {
|
|
1688
2266
|
const ctx = propertyName ? target : target.prototype;
|
|
@@ -1697,6 +2275,12 @@ function Middleware(middleware, opts) {
|
|
|
1697
2275
|
|
|
1698
2276
|
//#endregion
|
|
1699
2277
|
//#region packages/core/src/Decorators/Http/MultipartFormData.ts
|
|
2278
|
+
/**
|
|
2279
|
+
* @class MultipartFormDataDecorator
|
|
2280
|
+
* @extends BaseDecorator<MultipartFormDataOptions>
|
|
2281
|
+
*
|
|
2282
|
+
* A decorator class that handles the metadata for HTTP request bodies.
|
|
2283
|
+
*/
|
|
1700
2284
|
var MultipartFormDataDecorator = class extends BaseDecorator {
|
|
1701
2285
|
/**
|
|
1702
2286
|
* @method created
|
|
@@ -1712,12 +2296,35 @@ var MultipartFormDataDecorator = class extends BaseDecorator {
|
|
|
1712
2296
|
});
|
|
1713
2297
|
}
|
|
1714
2298
|
};
|
|
2299
|
+
/**
|
|
2300
|
+
* Decorator function that marks a parameter as multipart/form-data request body.
|
|
2301
|
+
* This decorator will automatically parse incoming multipart form data
|
|
2302
|
+
*
|
|
2303
|
+
* @decorator
|
|
2304
|
+
* @returns {Function} A decorator function that can be applied to method parameters
|
|
2305
|
+
*
|
|
2306
|
+
* @example
|
|
2307
|
+
* class UserController {
|
|
2308
|
+
* uploadFile(@MultipartFormData() formData: MyData) {
|
|
2309
|
+
* // Handle multipart form data
|
|
2310
|
+
* }
|
|
2311
|
+
* }
|
|
2312
|
+
*/
|
|
1715
2313
|
function MultipartFormData() {
|
|
1716
2314
|
return createDecorator(MultipartFormDataDecorator, {});
|
|
1717
2315
|
}
|
|
1718
2316
|
|
|
1719
2317
|
//#endregion
|
|
1720
2318
|
//#region packages/core/src/Decorators/Http/Session.ts
|
|
2319
|
+
/**
|
|
2320
|
+
* This class is responsible for managing session decorators.
|
|
2321
|
+
*
|
|
2322
|
+
* This class extends the BaseDecorator and is used to register session information
|
|
2323
|
+
* with the MetadataResolver. It ensures that the metadata for the property is created
|
|
2324
|
+
* and adds the session information to the metadata.
|
|
2325
|
+
*
|
|
2326
|
+
* @extends {BaseDecorator<{}>}
|
|
2327
|
+
*/
|
|
1721
2328
|
var SessionDecorator = class extends BaseDecorator {
|
|
1722
2329
|
gRuntimeConfig;
|
|
1723
2330
|
/**
|
|
@@ -1741,12 +2348,23 @@ var SessionDecorator = class extends BaseDecorator {
|
|
|
1741
2348
|
}
|
|
1742
2349
|
};
|
|
1743
2350
|
__decorate([Inject(RuntimeConfig)], SessionDecorator.prototype, "gRuntimeConfig", void 0);
|
|
2351
|
+
/**
|
|
2352
|
+
* A factory function for creating a SessionDecorator.
|
|
2353
|
+
*
|
|
2354
|
+
* This function returns a decorator function that can be used to annotate
|
|
2355
|
+
* a method parameter with session information.
|
|
2356
|
+
*
|
|
2357
|
+
* @return {Function} The decorator function.
|
|
2358
|
+
*/
|
|
1744
2359
|
function Session() {
|
|
1745
2360
|
return createDecorator(SessionDecorator, {});
|
|
1746
2361
|
}
|
|
1747
2362
|
|
|
1748
2363
|
//#endregion
|
|
1749
2364
|
//#region packages/core/src/Decorators/Hooks/Listen.ts
|
|
2365
|
+
/**
|
|
2366
|
+
* This class is responsible for managing cache decorator.
|
|
2367
|
+
*/
|
|
1750
2368
|
var ListenDecorator = class extends BaseDecorator {
|
|
1751
2369
|
gHooksService;
|
|
1752
2370
|
fHook;
|
|
@@ -1765,12 +2383,22 @@ var ListenDecorator = class extends BaseDecorator {
|
|
|
1765
2383
|
}
|
|
1766
2384
|
};
|
|
1767
2385
|
__decorate([Inject(HooksService)], ListenDecorator.prototype, "gHooksService", void 0);
|
|
2386
|
+
/**
|
|
2387
|
+
* This decorator stores metadata about hook listeners. It can be later used along with function
|
|
2388
|
+
* applyEventListeners() to automatically register all listeners.
|
|
2389
|
+
*
|
|
2390
|
+
* @param hookType hook to listen for
|
|
2391
|
+
* @return decorator function
|
|
2392
|
+
*/
|
|
1768
2393
|
function Listen(hookType) {
|
|
1769
2394
|
return createDecorator(ListenDecorator, { hookType });
|
|
1770
2395
|
}
|
|
1771
2396
|
|
|
1772
2397
|
//#endregion
|
|
1773
2398
|
//#region packages/core/src/Services/Plugins/BasePlugin.ts
|
|
2399
|
+
/**
|
|
2400
|
+
* Represents a Plugin.
|
|
2401
|
+
*/
|
|
1774
2402
|
var BasePlugin = class {
|
|
1775
2403
|
/**
|
|
1776
2404
|
* The name of the plugin.
|
|
@@ -1786,10 +2414,17 @@ var BasePlugin = class {
|
|
|
1786
2414
|
|
|
1787
2415
|
//#endregion
|
|
1788
2416
|
//#region packages/core/src/Services/Middleware/BaseMiddleware.ts
|
|
2417
|
+
/**
|
|
2418
|
+
* BaseMiddleware class that serves as a base for all middleware implementations.
|
|
2419
|
+
*/
|
|
1789
2420
|
var BaseMiddleware = class {};
|
|
1790
2421
|
|
|
1791
2422
|
//#endregion
|
|
1792
2423
|
//#region packages/core/src/Errors/Http/ForbiddenError.ts
|
|
2424
|
+
/**
|
|
2425
|
+
* Represents a Forbidden error (HTTP 403).
|
|
2426
|
+
* @extends {HttpError}
|
|
2427
|
+
*/
|
|
1793
2428
|
var ForbiddenError = class ForbiddenError extends HttpError {
|
|
1794
2429
|
/**
|
|
1795
2430
|
* The name of the error.
|
|
@@ -1809,6 +2444,10 @@ var ForbiddenError = class ForbiddenError extends HttpError {
|
|
|
1809
2444
|
|
|
1810
2445
|
//#endregion
|
|
1811
2446
|
//#region packages/core/src/Errors/Http/MethodNotAllowedError.ts
|
|
2447
|
+
/**
|
|
2448
|
+
* Represents a Method Not Allowed error (HTTP 405).
|
|
2449
|
+
* @extends {HttpError}
|
|
2450
|
+
*/
|
|
1812
2451
|
var MethodNotAllowedError = class MethodNotAllowedError extends HttpError {
|
|
1813
2452
|
/**
|
|
1814
2453
|
* The name of the error.
|
|
@@ -1828,6 +2467,10 @@ var MethodNotAllowedError = class MethodNotAllowedError extends HttpError {
|
|
|
1828
2467
|
|
|
1829
2468
|
//#endregion
|
|
1830
2469
|
//#region packages/core/src/Errors/Http/NotAcceptableError.ts
|
|
2470
|
+
/**
|
|
2471
|
+
* Represents a Not Acceptable error (HTTP 406).
|
|
2472
|
+
* @extends {HttpError}
|
|
2473
|
+
*/
|
|
1831
2474
|
var NotAcceptableError = class NotAcceptableError extends HttpError {
|
|
1832
2475
|
/**
|
|
1833
2476
|
* The name of the error.
|
|
@@ -1847,6 +2490,10 @@ var NotAcceptableError = class NotAcceptableError extends HttpError {
|
|
|
1847
2490
|
|
|
1848
2491
|
//#endregion
|
|
1849
2492
|
//#region packages/core/src/Errors/Http/NotFoundError.ts
|
|
2493
|
+
/**
|
|
2494
|
+
* Represents a Not Found error (HTTP 404).
|
|
2495
|
+
* @extends {HttpError}
|
|
2496
|
+
*/
|
|
1850
2497
|
var NotFoundError = class NotFoundError extends HttpError {
|
|
1851
2498
|
/**
|
|
1852
2499
|
* The name of the error.
|
|
@@ -1866,6 +2513,10 @@ var NotFoundError = class NotFoundError extends HttpError {
|
|
|
1866
2513
|
|
|
1867
2514
|
//#endregion
|
|
1868
2515
|
//#region packages/core/src/Errors/Http/UnauthorizedError.ts
|
|
2516
|
+
/**
|
|
2517
|
+
* Represents an Unauthorized error (HTTP 401).
|
|
2518
|
+
* @extends {HttpError}
|
|
2519
|
+
*/
|
|
1869
2520
|
var UnauthorizedError = class UnauthorizedError extends HttpError {
|
|
1870
2521
|
/**
|
|
1871
2522
|
* The name of the error.
|
|
@@ -1951,4 +2602,4 @@ let HTTPStatus = /* @__PURE__ */ function(HTTPStatus$1) {
|
|
|
1951
2602
|
}({});
|
|
1952
2603
|
|
|
1953
2604
|
//#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 };
|
|
2605
|
+
export { App, BadRequestError, BaseMiddleware, BasePlugin, Body, Connect, Controller, Delete, ErrorHandlerProvider, 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 };
|