@heliosjs/middlewares 3.0.0 → 4.0.2
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/catch.d.ts +3 -3
- package/dist/catch.js +9 -7
- package/dist/catch.js.map +1 -1
- package/dist/constants.d.ts +5 -1
- package/dist/constants.js +7 -2
- package/dist/constants.js.map +1 -1
- package/dist/cors.js +4 -6
- package/dist/cors.js.map +1 -1
- package/dist/guard.d.ts +44 -0
- package/dist/guard.js +58 -0
- package/dist/guard.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/interceptor.d.ts +45 -0
- package/dist/interceptor.js +59 -0
- package/dist/interceptor.js.map +1 -0
- package/dist/pipe.d.ts +31 -0
- package/dist/pipe.js +45 -0
- package/dist/pipe.js.map +1 -0
- package/dist/sanitize.js +4 -7
- package/dist/sanitize.js.map +1 -1
- package/dist/status.d.ts +4 -4
- package/dist/status.js +6 -8
- package/dist/status.js.map +1 -1
- package/dist/types/core/controller.d.ts +42 -22
- package/dist/types/core/error.d.ts +1 -2
- package/dist/types/core/error.js +0 -1
- package/dist/types/core/error.js.map +1 -1
- package/dist/use.d.ts +45 -1
- package/dist/use.js +52 -5
- package/dist/use.js.map +1 -1
- package/dist/utils/shared/helpers.d.ts +8 -3
- package/dist/utils/shared/helpers.js +74 -11
- package/dist/utils/shared/helpers.js.map +1 -1
- package/package.json +2 -2
- package/dist/helper.d.ts +0 -1
- package/dist/helper.js +0 -6
- package/dist/helper.js.map +0 -1
package/dist/catch.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ErrorHandler } from './types/core';
|
|
2
2
|
/**
|
|
3
3
|
* Decorator to register a global or controller-level error handler.
|
|
4
4
|
*
|
|
@@ -7,7 +7,7 @@ import { ErorrHandler } from './types/core';
|
|
|
7
7
|
* It attaches the handler as metadata on the target class, allowing the framework to
|
|
8
8
|
* retrieve and execute the error handler appropriately during runtime.
|
|
9
9
|
*
|
|
10
|
-
* @param {
|
|
10
|
+
* @param {ErrorHandler} handler - The error callback function to handle errors.
|
|
11
11
|
*
|
|
12
12
|
* @returns {Function} A class decorator function that defines the error handler metadata.
|
|
13
13
|
*
|
|
@@ -26,4 +26,4 @@ import { ErorrHandler } from './types/core';
|
|
|
26
26
|
* This metadata is accessible via Reflect API and used internally by the framework
|
|
27
27
|
* to invoke the registered error handler when errors occur.
|
|
28
28
|
*/
|
|
29
|
-
export declare function Catch(handler:
|
|
29
|
+
export declare function Catch(handler: ErrorHandler): (target: any, propertyKey?: string, descriptor?: PropertyDescriptor) => void;
|
package/dist/catch.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Catch = Catch;
|
|
4
|
-
const constants_1 = require("./constants");
|
|
5
4
|
const shared_1 = require("./utils/shared");
|
|
6
5
|
/**
|
|
7
6
|
* Decorator to register a global or controller-level error handler.
|
|
@@ -11,7 +10,7 @@ const shared_1 = require("./utils/shared");
|
|
|
11
10
|
* It attaches the handler as metadata on the target class, allowing the framework to
|
|
12
11
|
* retrieve and execute the error handler appropriately during runtime.
|
|
13
12
|
*
|
|
14
|
-
* @param {
|
|
13
|
+
* @param {ErrorHandler} handler - The error callback function to handle errors.
|
|
15
14
|
*
|
|
16
15
|
* @returns {Function} A class decorator function that defines the error handler metadata.
|
|
17
16
|
*
|
|
@@ -31,11 +30,14 @@ const shared_1 = require("./utils/shared");
|
|
|
31
30
|
* to invoke the registered error handler when errors occur.
|
|
32
31
|
*/
|
|
33
32
|
function Catch(handler) {
|
|
34
|
-
return function (target) {
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
return function (target, propertyKey, descriptor) {
|
|
34
|
+
const data = { errors: [handler] };
|
|
35
|
+
if (descriptor) {
|
|
36
|
+
(0, shared_1.defineMiddlewaresMeta)(data, target, propertyKey);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
(0, shared_1.defineMiddlewaresMeta)(data, target);
|
|
40
|
+
}
|
|
39
41
|
};
|
|
40
42
|
}
|
|
41
43
|
//# sourceMappingURL=catch.js.map
|
package/dist/catch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catch.js","sourceRoot":"","sources":["../src/catch.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"catch.js","sourceRoot":"","sources":["../src/catch.ts"],"names":[],"mappings":";;AA6BA,sBAUC;AAtCD,2CAAuD;AACvD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,SAAgB,KAAK,CAAC,OAAqB;IACzC,OAAO,UAAU,MAAW,EAAE,WAAoB,EAAE,UAA+B;QACjF,MAAM,IAAI,GAAG,EAAE,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;QAEnC,IAAI,UAAU,EAAE,CAAC;YACf,IAAA,8BAAqB,EAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;QACnD,CAAC;aAAM,CAAC;YACN,IAAA,8BAAqB,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACtC,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -23,4 +23,8 @@ export declare const SSE_METADATA_KEY = "sse:handlers";
|
|
|
23
23
|
export declare const SSE_TOPIC_KEY = "sse:topics";
|
|
24
24
|
export declare const SSE_SERVICE_KEY = "sse:service";
|
|
25
25
|
export declare const STATIC_METADATA_KEY = "static:config";
|
|
26
|
-
export declare
|
|
26
|
+
export declare enum DECORATOR {
|
|
27
|
+
controller = "controller:config",
|
|
28
|
+
middlewares = "controller:middlewares",
|
|
29
|
+
route = "controller:route"
|
|
30
|
+
}
|
package/dist/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.DECORATOR = exports.STATIC_METADATA_KEY = exports.SSE_SERVICE_KEY = exports.SSE_TOPIC_KEY = exports.SSE_METADATA_KEY = exports.CORS_METADATA = exports.TO_VALIDATE = exports.OK_STATUSES = exports.STOPPED = exports.SANITIZE = exports.CATCH = exports.INTERCEPT = exports.WS_SERVICE_KEY = exports.WS_TOPIC_KEY = exports.WS_HANDLER = exports.USE_MIDDLEWARE = exports.SERVER_CONFIG_KEY = exports.OK_METADATA_KEY = exports.ENDPOINT = exports.INTERCEPTOR = exports.CONTROLLERS = exports.MIDDLEWARES = exports.ROUTE_MIDDLEWARES = exports.ROUTE_PREFIX = exports.APP_METADATA_KEY = exports.PARAM_METADATA_KEY = void 0;
|
|
4
4
|
exports.PARAM_METADATA_KEY = 'design:parameters';
|
|
5
5
|
exports.APP_METADATA_KEY = 'app:configuration';
|
|
6
6
|
exports.ROUTE_PREFIX = 'route:prefix';
|
|
@@ -31,5 +31,10 @@ exports.SSE_METADATA_KEY = 'sse:handlers';
|
|
|
31
31
|
exports.SSE_TOPIC_KEY = 'sse:topics';
|
|
32
32
|
exports.SSE_SERVICE_KEY = 'sse:service';
|
|
33
33
|
exports.STATIC_METADATA_KEY = 'static:config';
|
|
34
|
-
|
|
34
|
+
var DECORATOR;
|
|
35
|
+
(function (DECORATOR) {
|
|
36
|
+
DECORATOR["controller"] = "controller:config";
|
|
37
|
+
DECORATOR["middlewares"] = "controller:middlewares";
|
|
38
|
+
DECORATOR["route"] = "controller:route";
|
|
39
|
+
})(DECORATOR || (exports.DECORATOR = DECORATOR = {}));
|
|
35
40
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,kBAAkB,GAAG,mBAAmB,CA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SAAS,QAIpB"}
|
package/dist/cors.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Cors = Cors;
|
|
4
|
-
const constants_1 = require("./constants");
|
|
5
4
|
const core_1 = require("./types/core");
|
|
6
5
|
const shared_1 = require("./utils/shared");
|
|
7
6
|
/**
|
|
@@ -47,13 +46,12 @@ function Cors(config = {}) {
|
|
|
47
46
|
methods: Object.keys(core_1.HTTP_METHODS),
|
|
48
47
|
};
|
|
49
48
|
const finalConfig = { ...defaultConfig, ...config };
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
const data = { cors: [finalConfig] };
|
|
50
|
+
if (descriptor) {
|
|
51
|
+
(0, shared_1.defineMiddlewaresMeta)(data, target, propertyKey);
|
|
52
52
|
}
|
|
53
53
|
else {
|
|
54
|
-
|
|
55
|
-
meta.cors.push(finalConfig);
|
|
56
|
-
Reflect.defineMetadata(constants_1.CONTROLLER_CONFIG, meta, target);
|
|
54
|
+
(0, shared_1.defineMiddlewaresMeta)(data, target);
|
|
57
55
|
}
|
|
58
56
|
};
|
|
59
57
|
}
|
package/dist/cors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cors.js","sourceRoot":"","sources":["../src/cors.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"cors.js","sourceRoot":"","sources":["../src/cors.ts"],"names":[],"mappings":";;AAsCA,oBAkBC;AAxDD,uCAAwD;AAExD,2CAAuD;AACvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,SAAgB,IAAI,CAAC,SAAqB,EAAE;IAC1C,OAAO,UAAU,MAAW,EAAE,WAAoB,EAAE,UAA+B;QACjF,MAAM,aAAa,GAAe;YAChC,MAAM,EAAE,GAAG;YACX,oBAAoB,EAAE,GAAG;YACzB,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,mBAAY,CAAC;SACnC,CAAC;QAEF,MAAM,WAAW,GAAG,EAAE,GAAG,aAAa,EAAE,GAAG,MAAM,EAAE,CAAC;QAEpD,MAAM,IAAI,GAAG,EAAE,IAAI,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC;QAErC,IAAI,UAAU,EAAE,CAAC;YACf,IAAA,8BAAqB,EAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;QACnD,CAAC;aAAM,CAAC;YACN,IAAA,8BAAqB,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACtC,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/guard.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type Guard, GuardFn } from './types/core';
|
|
2
|
+
/**
|
|
3
|
+
* Decorator to register a guard.
|
|
4
|
+
*
|
|
5
|
+
* Guards are used to control access to a controller by validating
|
|
6
|
+
* incoming requests before they reach route handlers. If a guard
|
|
7
|
+
* returns `false`, the request is blocked.
|
|
8
|
+
*
|
|
9
|
+
* @param guard - A guard class or function used to determine whether
|
|
10
|
+
* the request is allowed to proceed.
|
|
11
|
+
*
|
|
12
|
+
* @returns A class decorator that attaches guard metadata to the target.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // Using function guard
|
|
16
|
+
* @Guard((req, res) => {
|
|
17
|
+
* return !!req.headers.authorization;
|
|
18
|
+
* })
|
|
19
|
+
* class MyController {}
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // Using class-based guard
|
|
23
|
+
* class AuthGuard {
|
|
24
|
+
* canActivate(req: Request, res: Response) {
|
|
25
|
+
* return !!req.headers.authorization;
|
|
26
|
+
* }
|
|
27
|
+
* }
|
|
28
|
+
*
|
|
29
|
+
* @Guard(AuthGuard)
|
|
30
|
+
* class MyController {}
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* Guards are executed before controller methods.
|
|
34
|
+
* They can be used for:
|
|
35
|
+
* - authentication
|
|
36
|
+
* - authorization
|
|
37
|
+
* - request validation
|
|
38
|
+
*
|
|
39
|
+
* If any guard returns `false`, the request handling is stopped.
|
|
40
|
+
*
|
|
41
|
+
* Metadata is stored under the CONTROLLER_CONFIGUARTION key and used
|
|
42
|
+
* internally by the framework during request processing.
|
|
43
|
+
*/
|
|
44
|
+
export declare function Guard(guard: Guard | GuardFn): (target: any, propertyKey?: string, descriptor?: PropertyDescriptor) => void;
|
package/dist/guard.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Guard = Guard;
|
|
4
|
+
const shared_1 = require("./utils/shared");
|
|
5
|
+
/**
|
|
6
|
+
* Decorator to register a guard.
|
|
7
|
+
*
|
|
8
|
+
* Guards are used to control access to a controller by validating
|
|
9
|
+
* incoming requests before they reach route handlers. If a guard
|
|
10
|
+
* returns `false`, the request is blocked.
|
|
11
|
+
*
|
|
12
|
+
* @param guard - A guard class or function used to determine whether
|
|
13
|
+
* the request is allowed to proceed.
|
|
14
|
+
*
|
|
15
|
+
* @returns A class decorator that attaches guard metadata to the target.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Using function guard
|
|
19
|
+
* @Guard((req, res) => {
|
|
20
|
+
* return !!req.headers.authorization;
|
|
21
|
+
* })
|
|
22
|
+
* class MyController {}
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // Using class-based guard
|
|
26
|
+
* class AuthGuard {
|
|
27
|
+
* canActivate(req: Request, res: Response) {
|
|
28
|
+
* return !!req.headers.authorization;
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
*
|
|
32
|
+
* @Guard(AuthGuard)
|
|
33
|
+
* class MyController {}
|
|
34
|
+
*
|
|
35
|
+
* @remarks
|
|
36
|
+
* Guards are executed before controller methods.
|
|
37
|
+
* They can be used for:
|
|
38
|
+
* - authentication
|
|
39
|
+
* - authorization
|
|
40
|
+
* - request validation
|
|
41
|
+
*
|
|
42
|
+
* If any guard returns `false`, the request handling is stopped.
|
|
43
|
+
*
|
|
44
|
+
* Metadata is stored under the CONTROLLER_CONFIGUARTION key and used
|
|
45
|
+
* internally by the framework during request processing.
|
|
46
|
+
*/
|
|
47
|
+
function Guard(guard) {
|
|
48
|
+
return function (target, propertyKey, descriptor) {
|
|
49
|
+
const data = { guards: [guard] };
|
|
50
|
+
if (descriptor) {
|
|
51
|
+
(0, shared_1.defineMiddlewaresMeta)(data, target, propertyKey);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
(0, shared_1.defineMiddlewaresMeta)(data, target);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guard.js","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":";;AA4CA,sBAUC;AArDD,2CAAuD;AACvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,SAAgB,KAAK,CAAC,KAAsB;IAC1C,OAAO,UAAU,MAAW,EAAE,WAAoB,EAAE,UAA+B;QACjF,MAAM,IAAI,GAAG,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;QAEjC,IAAI,UAAU,EAAE,CAAC;YACf,IAAA,8BAAqB,EAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;QACnD,CAAC;aAAM,CAAC;YACN,IAAA,8BAAqB,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACtC,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -17,6 +17,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
require("reflect-metadata");
|
|
18
18
|
__exportStar(require("./catch"), exports);
|
|
19
19
|
__exportStar(require("./cors"), exports);
|
|
20
|
+
__exportStar(require("./guard"), exports);
|
|
21
|
+
__exportStar(require("./interceptor"), exports);
|
|
22
|
+
__exportStar(require("./pipe"), exports);
|
|
20
23
|
__exportStar(require("./sanitize"), exports);
|
|
21
24
|
__exportStar(require("./status"), exports);
|
|
22
25
|
__exportStar(require("./use"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4BAA0B;AAC1B,0CAAwB;AACxB,yCAAuB;AACvB,6CAA2B;AAC3B,2CAAyB;AACzB,wCAAsB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4BAA0B;AAC1B,0CAAwB;AACxB,yCAAuB;AACvB,0CAAwB;AACxB,gDAA8B;AAC9B,yCAAuB;AACvB,6CAA2B;AAC3B,2CAAyB;AACzB,wCAAsB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { InterceptorCB } from '@heliosjs/core';
|
|
2
|
+
/**
|
|
3
|
+
* Decorator to register an interceptor at the controller or method level.
|
|
4
|
+
*
|
|
5
|
+
* Interceptors are functions that wrap the execution of a route handler.
|
|
6
|
+
* They can run logic before after the handler is executed, allowing
|
|
7
|
+
* you to modify responses, or handle cross-cutting concerns.
|
|
8
|
+
*
|
|
9
|
+
* @param handler - Interceptor callback function.
|
|
10
|
+
*
|
|
11
|
+
* @returns A decorator that attaches interceptor metadata to the target
|
|
12
|
+
* (either a class or a method).
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // Logging interceptor
|
|
16
|
+
* @Intercept(async (ctx, next) => {
|
|
17
|
+
* console.log('Before');
|
|
18
|
+
* const result = await next();
|
|
19
|
+
* console.log('After');
|
|
20
|
+
* return result;
|
|
21
|
+
* })
|
|
22
|
+
* class MyController {}
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // Method-level interceptor
|
|
26
|
+
* class MyController {
|
|
27
|
+
* @Intercept(async (ctx, next) => {
|
|
28
|
+
* return next();
|
|
29
|
+
* })
|
|
30
|
+
* getData() {}
|
|
31
|
+
* }
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* - Interceptors can modify the result returned by the handler.
|
|
35
|
+
* - They are executed in the order they are applied.
|
|
36
|
+
* - Can be used for:
|
|
37
|
+
* - logging
|
|
38
|
+
* - response transformation
|
|
39
|
+
* - caching
|
|
40
|
+
* - error handling (wrapping)
|
|
41
|
+
*
|
|
42
|
+
* Metadata is stored using the MIDDLEWARES_CONFIG key and
|
|
43
|
+
* used internally by the framework during request processing.
|
|
44
|
+
*/
|
|
45
|
+
export declare function Intercept(handler: InterceptorCB): (target: any, propertyKey?: string, descriptor?: PropertyDescriptor) => void;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Intercept = Intercept;
|
|
4
|
+
const shared_1 = require("./utils/shared");
|
|
5
|
+
/**
|
|
6
|
+
* Decorator to register an interceptor at the controller or method level.
|
|
7
|
+
*
|
|
8
|
+
* Interceptors are functions that wrap the execution of a route handler.
|
|
9
|
+
* They can run logic before after the handler is executed, allowing
|
|
10
|
+
* you to modify responses, or handle cross-cutting concerns.
|
|
11
|
+
*
|
|
12
|
+
* @param handler - Interceptor callback function.
|
|
13
|
+
*
|
|
14
|
+
* @returns A decorator that attaches interceptor metadata to the target
|
|
15
|
+
* (either a class or a method).
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Logging interceptor
|
|
19
|
+
* @Intercept(async (ctx, next) => {
|
|
20
|
+
* console.log('Before');
|
|
21
|
+
* const result = await next();
|
|
22
|
+
* console.log('After');
|
|
23
|
+
* return result;
|
|
24
|
+
* })
|
|
25
|
+
* class MyController {}
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // Method-level interceptor
|
|
29
|
+
* class MyController {
|
|
30
|
+
* @Intercept(async (ctx, next) => {
|
|
31
|
+
* return next();
|
|
32
|
+
* })
|
|
33
|
+
* getData() {}
|
|
34
|
+
* }
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* - Interceptors can modify the result returned by the handler.
|
|
38
|
+
* - They are executed in the order they are applied.
|
|
39
|
+
* - Can be used for:
|
|
40
|
+
* - logging
|
|
41
|
+
* - response transformation
|
|
42
|
+
* - caching
|
|
43
|
+
* - error handling (wrapping)
|
|
44
|
+
*
|
|
45
|
+
* Metadata is stored using the MIDDLEWARES_CONFIG key and
|
|
46
|
+
* used internally by the framework during request processing.
|
|
47
|
+
*/
|
|
48
|
+
function Intercept(handler) {
|
|
49
|
+
return function (target, propertyKey, descriptor) {
|
|
50
|
+
const data = { interceptors: [handler] };
|
|
51
|
+
if (descriptor) {
|
|
52
|
+
(0, shared_1.defineMiddlewaresMeta)(data, target, propertyKey);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
(0, shared_1.defineMiddlewaresMeta)(data, target);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=interceptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interceptor.js","sourceRoot":"","sources":["../src/interceptor.ts"],"names":[],"mappings":";;AA6CA,8BAUC;AAtDD,2CAAuD;AACvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,SAAgB,SAAS,CAAC,OAAsB;IAC9C,OAAO,UAAU,MAAW,EAAE,WAAoB,EAAE,UAA+B;QACjF,MAAM,IAAI,GAAG,EAAE,YAAY,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;QAEzC,IAAI,UAAU,EAAE,CAAC;YACf,IAAA,8BAAqB,EAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;QACnD,CAAC;aAAM,CAAC;YACN,IAAA,8BAAqB,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACtC,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/pipe.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Pipe } from './types/core';
|
|
2
|
+
/**
|
|
3
|
+
* Decorator to register a data transformation pipe.
|
|
4
|
+
*
|
|
5
|
+
* Pipes are used to transform incoming request data before it reaches
|
|
6
|
+
* the route handler. They can be applied at the controller level and
|
|
7
|
+
* modify parts of the request such as body, query, params, or headers.
|
|
8
|
+
*
|
|
9
|
+
* @param config - Configuration object containing transformation functions
|
|
10
|
+
* for different parts of the request.
|
|
11
|
+
*
|
|
12
|
+
* @returns A class decorator that attaches pipe metadata to the target.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* @Pipe({
|
|
16
|
+
* body: (body) => ({ ...body, name: body.name.trim() }),
|
|
17
|
+
* query: (query) => ({ ...query, page: Number(query.page) }),
|
|
18
|
+
* })
|
|
19
|
+
* class MyController {}
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* Each function in the pipe receives raw data and must return the transformed value.
|
|
23
|
+
* Pipes are executed before controller methods and can be used for:
|
|
24
|
+
* - data normalization
|
|
25
|
+
* - type casting
|
|
26
|
+
* - sanitization
|
|
27
|
+
*
|
|
28
|
+
* Metadata is stored under the CONTROLLER_CONFIGUARTION key and later used
|
|
29
|
+
* by the framework during request processing.
|
|
30
|
+
*/
|
|
31
|
+
export declare function Pipe(pipe: Pipe): (target: any, propertyKey?: string, descriptor?: PropertyDescriptor) => void;
|
package/dist/pipe.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Pipe = Pipe;
|
|
4
|
+
const shared_1 = require("./utils/shared");
|
|
5
|
+
/**
|
|
6
|
+
* Decorator to register a data transformation pipe.
|
|
7
|
+
*
|
|
8
|
+
* Pipes are used to transform incoming request data before it reaches
|
|
9
|
+
* the route handler. They can be applied at the controller level and
|
|
10
|
+
* modify parts of the request such as body, query, params, or headers.
|
|
11
|
+
*
|
|
12
|
+
* @param config - Configuration object containing transformation functions
|
|
13
|
+
* for different parts of the request.
|
|
14
|
+
*
|
|
15
|
+
* @returns A class decorator that attaches pipe metadata to the target.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* @Pipe({
|
|
19
|
+
* body: (body) => ({ ...body, name: body.name.trim() }),
|
|
20
|
+
* query: (query) => ({ ...query, page: Number(query.page) }),
|
|
21
|
+
* })
|
|
22
|
+
* class MyController {}
|
|
23
|
+
*
|
|
24
|
+
* @remarks
|
|
25
|
+
* Each function in the pipe receives raw data and must return the transformed value.
|
|
26
|
+
* Pipes are executed before controller methods and can be used for:
|
|
27
|
+
* - data normalization
|
|
28
|
+
* - type casting
|
|
29
|
+
* - sanitization
|
|
30
|
+
*
|
|
31
|
+
* Metadata is stored under the CONTROLLER_CONFIGUARTION key and later used
|
|
32
|
+
* by the framework during request processing.
|
|
33
|
+
*/
|
|
34
|
+
function Pipe(pipe) {
|
|
35
|
+
return function (target, propertyKey, descriptor) {
|
|
36
|
+
const data = { pipes: [pipe] };
|
|
37
|
+
if (descriptor) {
|
|
38
|
+
(0, shared_1.defineMiddlewaresMeta)(data, target, propertyKey);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
(0, shared_1.defineMiddlewaresMeta)(data, target);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=pipe.js.map
|
package/dist/pipe.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipe.js","sourceRoot":"","sources":["../src/pipe.ts"],"names":[],"mappings":";;AA+BA,oBAUC;AAxCD,2CAAuD;AACvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,SAAgB,IAAI,CAAC,IAAU;IAC7B,OAAO,UAAU,MAAW,EAAE,WAAoB,EAAE,UAA+B;QACjF,MAAM,IAAI,GAAG,EAAE,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAE/B,IAAI,UAAU,EAAE,CAAC;YACf,IAAA,8BAAqB,EAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;QACnD,CAAC;aAAM,CAAC;YACN,IAAA,8BAAqB,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACtC,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/sanitize.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Sanitize = Sanitize;
|
|
4
|
-
const constants_1 = require("./constants");
|
|
5
4
|
const shared_1 = require("./utils/shared");
|
|
6
5
|
/**
|
|
7
6
|
* Decorator to apply sanitization configurations to a controller or method.
|
|
@@ -43,14 +42,12 @@ const shared_1 = require("./utils/shared");
|
|
|
43
42
|
*/
|
|
44
43
|
function Sanitize(sanitizeConfig) {
|
|
45
44
|
return function (target, propertyKey, descriptor) {
|
|
46
|
-
const
|
|
47
|
-
if (
|
|
48
|
-
|
|
45
|
+
const data = { sanitizers: Array.isArray(sanitizeConfig) ? sanitizeConfig : [sanitizeConfig] };
|
|
46
|
+
if (descriptor) {
|
|
47
|
+
(0, shared_1.defineMiddlewaresMeta)(data, target, propertyKey);
|
|
49
48
|
}
|
|
50
49
|
else {
|
|
51
|
-
|
|
52
|
-
meta.sanitizers.push(...configs);
|
|
53
|
-
Reflect.defineMetadata(constants_1.CONTROLLER_CONFIG, meta, target);
|
|
50
|
+
(0, shared_1.defineMiddlewaresMeta)(data, target);
|
|
54
51
|
}
|
|
55
52
|
};
|
|
56
53
|
}
|
package/dist/sanitize.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitize.js","sourceRoot":"","sources":["../src/sanitize.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"sanitize.js","sourceRoot":"","sources":["../src/sanitize.ts"],"names":[],"mappings":";;AAwCA,4BAUC;AAjDD,2CAAuD;AACvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,SAAgB,QAAQ,CAAC,cAAmD;IAC1E,OAAO,UAAU,MAAW,EAAE,WAAoB,EAAE,UAA+B;QACjF,MAAM,IAAI,GAAG,EAAE,UAAU,EAAE,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,EAAE,CAAC;QAE/F,IAAI,UAAU,EAAE,CAAC;YACf,IAAA,8BAAqB,EAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;QACnD,CAAC;aAAM,CAAC;YACN,IAAA,8BAAqB,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACtC,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/status.d.ts
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
* This metadata is accessible via Reflect API and used internally by the framework
|
|
32
32
|
* to set the HTTP response status.
|
|
33
33
|
*/
|
|
34
|
-
export declare function Status(status: number): (target: any, propertyKey?: string
|
|
34
|
+
export declare function Status(status: number): (target: any, propertyKey?: string) => void;
|
|
35
35
|
/**
|
|
36
36
|
* Shortcut decorator to set HTTP 200 OK status.
|
|
37
37
|
*
|
|
@@ -40,7 +40,7 @@ export declare function Status(status: number): (target: any, propertyKey?: stri
|
|
|
40
40
|
*
|
|
41
41
|
* @returns {Function} A decorator function that sets the HTTP status to 200.
|
|
42
42
|
*/
|
|
43
|
-
export declare const Ok200: () => (target: any, propertyKey?: string
|
|
43
|
+
export declare const Ok200: () => (target: any, propertyKey?: string) => void;
|
|
44
44
|
/**
|
|
45
45
|
* Shortcut decorator to set HTTP 201 Created status.
|
|
46
46
|
*
|
|
@@ -49,7 +49,7 @@ export declare const Ok200: () => (target: any, propertyKey?: string | symbol, d
|
|
|
49
49
|
*
|
|
50
50
|
* @returns {Function} A decorator function that sets the HTTP status to 201.
|
|
51
51
|
*/
|
|
52
|
-
export declare const Ok201: () => (target: any, propertyKey?: string
|
|
52
|
+
export declare const Ok201: () => (target: any, propertyKey?: string) => void;
|
|
53
53
|
/**
|
|
54
54
|
* Shortcut decorator to set HTTP 204 No Content status.
|
|
55
55
|
*
|
|
@@ -59,4 +59,4 @@ export declare const Ok201: () => (target: any, propertyKey?: string | symbol, d
|
|
|
59
59
|
*
|
|
60
60
|
* @returns {Function} A decorator function that sets the HTTP status to 204.
|
|
61
61
|
*/
|
|
62
|
-
export declare const Ok204: () => (target: any, propertyKey?: string
|
|
62
|
+
export declare const Ok204: () => (target: any, propertyKey?: string) => void;
|
package/dist/status.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Ok204 = exports.Ok201 = exports.Ok200 = void 0;
|
|
4
4
|
exports.Status = Status;
|
|
5
|
-
const
|
|
5
|
+
const shared_1 = require("./utils/shared");
|
|
6
6
|
/**
|
|
7
7
|
* Decorator to set the HTTP status code for the response.
|
|
8
8
|
*
|
|
@@ -37,13 +37,11 @@ const constants_1 = require("./constants");
|
|
|
37
37
|
* to set the HTTP response status.
|
|
38
38
|
*/
|
|
39
39
|
function Status(status) {
|
|
40
|
-
return function (target, propertyKey
|
|
41
|
-
if (
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (descriptor) {
|
|
46
|
-
Reflect.defineMetadata(constants_1.OK_METADATA_KEY, status, target, propertyKey);
|
|
40
|
+
return function (target, propertyKey) {
|
|
41
|
+
if (propertyKey) {
|
|
42
|
+
const meta = (0, shared_1.reflectMiddlewaresMetadata)(target);
|
|
43
|
+
meta.status = status;
|
|
44
|
+
(0, shared_1.defineMiddlewaresMeta)(meta, target, propertyKey);
|
|
47
45
|
}
|
|
48
46
|
};
|
|
49
47
|
}
|
package/dist/status.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.js","sourceRoot":"","sources":["../src/status.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../src/status.ts"],"names":[],"mappings":";;;AAkCA,wBAQC;AA1CD,2CAAmF;AACnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,SAAgB,MAAM,CAAC,MAAc;IACnC,OAAO,UAAU,MAAW,EAAE,WAAoB;QAChD,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,IAAI,GAAG,IAAA,mCAA0B,EAAC,MAAM,CAAC,CAAC;YAChD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;YACrB,IAAA,8BAAqB,EAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;QACnD,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACI,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAA1B,QAAA,KAAK,SAAqB;AAEvC;;;;;;;GAOG;AACI,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAA1B,QAAA,KAAK,SAAqB;AAEvC;;;;;;;;GAQG;AACI,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAA1B,QAAA,KAAK,SAAqB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HTTP_METHODS, InterceptorCB, MiddlewareCB, ParamMetadata } from './common';
|
|
2
2
|
import { CORSConfig } from './cors';
|
|
3
|
-
import {
|
|
3
|
+
import { ErrorHandler } from './error';
|
|
4
4
|
import { Request } from './request';
|
|
5
5
|
import { Response } from './response';
|
|
6
6
|
import { SanitizerConfig } from './sanitize';
|
|
@@ -24,8 +24,6 @@ export interface ControllerConfig {
|
|
|
24
24
|
prefix: string;
|
|
25
25
|
middlewares?: Array<MiddlewareCB>;
|
|
26
26
|
controllers?: ControllerInstance[];
|
|
27
|
-
interceptor?: InterceptorCB;
|
|
28
|
-
cors?: CORSConfig;
|
|
29
27
|
}
|
|
30
28
|
export type SSE_HANDLER_META = {
|
|
31
29
|
type: string;
|
|
@@ -56,45 +54,67 @@ export type SeeControllerHandlers = {
|
|
|
56
54
|
error: HandlerMeta[];
|
|
57
55
|
};
|
|
58
56
|
};
|
|
57
|
+
export type FunctionsMeta = {
|
|
58
|
+
middlewares: MiddlewareCB[];
|
|
59
|
+
errors: ErrorHandler[];
|
|
60
|
+
cors: CORSConfig[];
|
|
61
|
+
sanitizers: SanitizerConfig[];
|
|
62
|
+
pipes: Pipe[];
|
|
63
|
+
guards: (Guard | GuardFn)[];
|
|
64
|
+
interceptors: InterceptorCB[];
|
|
65
|
+
status?: number;
|
|
66
|
+
};
|
|
59
67
|
export type Route = {
|
|
60
68
|
name: string;
|
|
61
69
|
route: string;
|
|
62
70
|
method: HTTP_METHODS;
|
|
63
71
|
cors?: CORSConfig[];
|
|
64
72
|
ok: number;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
functions:
|
|
68
|
-
sanitizers: SanitizerConfig[];
|
|
69
|
-
errors: ErorrHandler[];
|
|
70
|
-
middlewares: MiddlewareCB[];
|
|
71
|
-
}[];
|
|
73
|
+
parameters: ParamMetadata[];
|
|
74
|
+
interceptor?: InterceptorCB;
|
|
75
|
+
functions: FunctionsMeta[];
|
|
72
76
|
fn: (...args: any[]) => any;
|
|
73
77
|
};
|
|
74
78
|
export type NextFunction = (error?: unknown) => void;
|
|
75
79
|
export type ControllerMeta = {
|
|
76
80
|
prefix: string;
|
|
81
|
+
name: string;
|
|
77
82
|
routes: Route[];
|
|
78
|
-
interceptors: InterceptorCB[];
|
|
79
|
-
cors: CORSConfig[];
|
|
80
|
-
functions: {
|
|
81
|
-
sanitizers: SanitizerConfig[];
|
|
82
|
-
errors: ErorrHandler[];
|
|
83
|
-
middlewares: MiddlewareCB[];
|
|
84
|
-
}[];
|
|
85
83
|
children?: ControllerMeta[];
|
|
84
|
+
functions: MiddlewaresMetadata[];
|
|
85
|
+
controllers: ControllerClass[];
|
|
86
86
|
};
|
|
87
87
|
export type ControllerMetadata = {
|
|
88
88
|
prefix: string;
|
|
89
89
|
name: string;
|
|
90
90
|
middlewares: MiddlewareCB[];
|
|
91
|
-
interceptor?: InterceptorCB;
|
|
92
91
|
controllers: ControllerInstance[];
|
|
93
|
-
cors?: CORSConfig;
|
|
94
92
|
};
|
|
95
|
-
export type
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
export type RouteMetadata = {
|
|
94
|
+
route: string;
|
|
95
|
+
method: HTTP_METHODS;
|
|
96
|
+
middlewares: MiddlewareCB[];
|
|
97
|
+
parameters: ParamMetadata[];
|
|
98
|
+
};
|
|
99
|
+
export type PipeKey = 'body' | 'query' | 'params' | 'headers';
|
|
100
|
+
export type Pipe = {
|
|
101
|
+
body?: (body: unknown, request: Request) => unknown;
|
|
102
|
+
query?: (query: Record<string, string | string[]>, request: Request) => Record<string, string | string[]>;
|
|
103
|
+
params?: (params: Record<string, string>, request: Request) => Record<string, string>;
|
|
104
|
+
headers?: (headers: Record<string, string | string[]>, request: Request) => Record<string, string | string[]>;
|
|
105
|
+
};
|
|
106
|
+
export interface Guard {
|
|
107
|
+
new (...any: any[]): any;
|
|
108
|
+
canActivate(request: Request, response: Response): boolean;
|
|
109
|
+
}
|
|
110
|
+
export type GuardFn = (request: Request, response: Response) => boolean;
|
|
111
|
+
export type MiddlewaresMetadata = {
|
|
112
|
+
middlewares: MiddlewareCB[];
|
|
113
|
+
errors: ErrorHandler[];
|
|
98
114
|
cors: CORSConfig[];
|
|
99
115
|
sanitizers: SanitizerConfig[];
|
|
116
|
+
pipes: Pipe[];
|
|
117
|
+
guards: (Guard | GuardFn)[];
|
|
118
|
+
interceptors: InterceptorCB[];
|
|
119
|
+
status?: number;
|
|
100
120
|
};
|
|
@@ -7,7 +7,6 @@ export declare enum ErrorCode {
|
|
|
7
7
|
NOT_FOUND = "NOT_FOUND",
|
|
8
8
|
VALIDATION_FAILED = "VALIDATION_FAILED",
|
|
9
9
|
RATE_LIMIT_EXCEEDED = "RATE_LIMIT_EXCEEDED",
|
|
10
|
-
INTERNAL_ERROR = "INTERNAL_ERROR",
|
|
11
10
|
SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE",
|
|
12
11
|
DATABASE_ERROR = "DATABASE_ERROR",
|
|
13
12
|
DUPLICATE_ENTRY = "DUPLICATE_ENTRY",
|
|
@@ -70,7 +69,7 @@ export interface ErrorHandlerConfig {
|
|
|
70
69
|
logStack?: boolean;
|
|
71
70
|
customHandlers?: Record<ErrorCode, (error: HeliosError) => unknown>;
|
|
72
71
|
}
|
|
73
|
-
export type
|
|
72
|
+
export type ErrorHandler = (error: Error, req: Request, response: Response) => unknown;
|
|
74
73
|
type ErrorChildren = {
|
|
75
74
|
property?: string;
|
|
76
75
|
value: unknown;
|
package/dist/types/core/error.js
CHANGED
|
@@ -9,7 +9,6 @@ var ErrorCode;
|
|
|
9
9
|
ErrorCode["NOT_FOUND"] = "NOT_FOUND";
|
|
10
10
|
ErrorCode["VALIDATION_FAILED"] = "VALIDATION_FAILED";
|
|
11
11
|
ErrorCode["RATE_LIMIT_EXCEEDED"] = "RATE_LIMIT_EXCEEDED";
|
|
12
|
-
ErrorCode["INTERNAL_ERROR"] = "INTERNAL_ERROR";
|
|
13
12
|
ErrorCode["SERVICE_UNAVAILABLE"] = "SERVICE_UNAVAILABLE";
|
|
14
13
|
ErrorCode["DATABASE_ERROR"] = "DATABASE_ERROR";
|
|
15
14
|
ErrorCode["DUPLICATE_ENTRY"] = "DUPLICATE_ENTRY";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/types/core/error.ts"],"names":[],"mappings":";;;AAGA,IAAY,
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/types/core/error.ts"],"names":[],"mappings":";;;AAGA,IAAY,SAaX;AAbD,WAAY,SAAS;IACnB,wCAA2B,CAAA;IAC3B,0CAA6B,CAAA;IAC7B,oCAAuB,CAAA;IACvB,oCAAuB,CAAA;IACvB,oDAAuC,CAAA;IACvC,wDAA2C,CAAA;IAC3C,wDAA2C,CAAA;IAC3C,8CAAiC,CAAA;IACjC,gDAAmC,CAAA;IACnC,4CAA+B,CAAA;IAC/B,oDAAuC,CAAA;IACvC,4DAA+C,CAAA;AACjD,CAAC,EAbW,SAAS,yBAAT,SAAS,QAapB"}
|
package/dist/use.d.ts
CHANGED
|
@@ -1,2 +1,46 @@
|
|
|
1
1
|
import { MiddlewareCB } from './types/core';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Decorator to register middleware(s) at the controller or method level.
|
|
4
|
+
*
|
|
5
|
+
* Middlewares are functions executed before the route handler.
|
|
6
|
+
* They can be used to:
|
|
7
|
+
* - modify request/response
|
|
8
|
+
* - perform logging
|
|
9
|
+
* - handle authentication/authorization
|
|
10
|
+
* - short-circuit request handling
|
|
11
|
+
*
|
|
12
|
+
* @param middleware - A single middleware function or an array of middleware functions.
|
|
13
|
+
*
|
|
14
|
+
* @returns A decorator that attaches middleware metadata to the target
|
|
15
|
+
* (either a class or a method).
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Single middleware
|
|
19
|
+
* @Use((req, res, next) => {
|
|
20
|
+
* console.log('Request received');
|
|
21
|
+
* next();
|
|
22
|
+
* })
|
|
23
|
+
* class MyController {}
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // Multiple middlewares
|
|
27
|
+
* @Use([
|
|
28
|
+
* authMiddleware,
|
|
29
|
+
* loggingMiddleware,
|
|
30
|
+
* ])
|
|
31
|
+
* class MyController {}
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* // Method-level middleware
|
|
35
|
+
* class MyController {
|
|
36
|
+
* @Use(authMiddleware)
|
|
37
|
+
* getData() {}
|
|
38
|
+
* }
|
|
39
|
+
*
|
|
40
|
+
* @remarks
|
|
41
|
+
* - Middlewares are executed in the order they are defined.
|
|
42
|
+
* - Can be applied at both class and method levels.
|
|
43
|
+
* - Metadata is stored using the MIDDLEWARES_CONFIG key and used
|
|
44
|
+
* internally by the framework during request handling.
|
|
45
|
+
*/
|
|
46
|
+
export declare function Use(middleware: MiddlewareCB | MiddlewareCB[]): (target: any, propertyKey?: string, descriptor?: PropertyDescriptor) => any;
|
package/dist/use.js
CHANGED
|
@@ -1,14 +1,61 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Use = Use;
|
|
4
|
-
const constants_1 = require("./constants");
|
|
5
4
|
const shared_1 = require("./utils/shared");
|
|
5
|
+
/**
|
|
6
|
+
* Decorator to register middleware(s) at the controller or method level.
|
|
7
|
+
*
|
|
8
|
+
* Middlewares are functions executed before the route handler.
|
|
9
|
+
* They can be used to:
|
|
10
|
+
* - modify request/response
|
|
11
|
+
* - perform logging
|
|
12
|
+
* - handle authentication/authorization
|
|
13
|
+
* - short-circuit request handling
|
|
14
|
+
*
|
|
15
|
+
* @param middleware - A single middleware function or an array of middleware functions.
|
|
16
|
+
*
|
|
17
|
+
* @returns A decorator that attaches middleware metadata to the target
|
|
18
|
+
* (either a class or a method).
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // Single middleware
|
|
22
|
+
* @Use((req, res, next) => {
|
|
23
|
+
* console.log('Request received');
|
|
24
|
+
* next();
|
|
25
|
+
* })
|
|
26
|
+
* class MyController {}
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* // Multiple middlewares
|
|
30
|
+
* @Use([
|
|
31
|
+
* authMiddleware,
|
|
32
|
+
* loggingMiddleware,
|
|
33
|
+
* ])
|
|
34
|
+
* class MyController {}
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* // Method-level middleware
|
|
38
|
+
* class MyController {
|
|
39
|
+
* @Use(authMiddleware)
|
|
40
|
+
* getData() {}
|
|
41
|
+
* }
|
|
42
|
+
*
|
|
43
|
+
* @remarks
|
|
44
|
+
* - Middlewares are executed in the order they are defined.
|
|
45
|
+
* - Can be applied at both class and method levels.
|
|
46
|
+
* - Metadata is stored using the MIDDLEWARES_CONFIG key and used
|
|
47
|
+
* internally by the framework during request handling.
|
|
48
|
+
*/
|
|
6
49
|
function Use(middleware) {
|
|
7
|
-
return function (target) {
|
|
50
|
+
return function (target, propertyKey, descriptor) {
|
|
8
51
|
const middlewares = Array.isArray(middleware) ? middleware : [middleware];
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
52
|
+
const data = { middlewares };
|
|
53
|
+
if (descriptor) {
|
|
54
|
+
(0, shared_1.defineMiddlewaresMeta)(data, target, propertyKey);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
(0, shared_1.defineMiddlewaresMeta)(data, target);
|
|
58
|
+
}
|
|
12
59
|
return target;
|
|
13
60
|
};
|
|
14
61
|
}
|
package/dist/use.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use.js","sourceRoot":"","sources":["../src/use.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"use.js","sourceRoot":"","sources":["../src/use.ts"],"names":[],"mappings":";;AA+CA,kBAcC;AA5DD,2CAAuD;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,SAAgB,GAAG,CAAC,UAAyC;IAC3D,OAAO,UAAU,MAAW,EAAE,WAAoB,EAAE,UAA+B;QACjF,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;QAE1E,MAAM,IAAI,GAAG,EAAE,WAAW,EAAE,CAAC;QAE7B,IAAI,UAAU,EAAE,CAAC;YACf,IAAA,8BAAqB,EAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;QACnD,CAAC;aAAM,CAAC;YACN,IAAA,8BAAqB,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACtC,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
import {
|
|
2
|
+
import { ControllerMeta, MiddlewaresMetadata, RouteMetadata } from '../../types/core/controller';
|
|
3
3
|
export declare const generateUniqueId: () => string;
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
4
|
+
export declare function reflectControllerMeta(target: object): ControllerMeta;
|
|
5
|
+
export declare function defineControllerMeta(meta: Partial<ControllerMeta>, target: object): void;
|
|
6
|
+
export declare function reflectMiddlewaresMetadata(target: any, propertie?: string): MiddlewaresMetadata;
|
|
7
|
+
export declare function reflectRouteMetadata(target: object, popertie: string): RouteMetadata;
|
|
8
|
+
export declare function defineMiddlewaresMeta(meta: Partial<MiddlewaresMetadata>, target: object): void;
|
|
9
|
+
export declare function defineMiddlewaresMeta(meta: Partial<MiddlewaresMetadata>, target: object, propertie?: string): void;
|
|
10
|
+
export declare function defineRouteMeta(meta: Partial<RouteMetadata>, target: object, propertie: string): void;
|
|
@@ -1,28 +1,91 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateUniqueId = void 0;
|
|
4
|
-
exports.
|
|
4
|
+
exports.reflectControllerMeta = reflectControllerMeta;
|
|
5
|
+
exports.defineControllerMeta = defineControllerMeta;
|
|
6
|
+
exports.reflectMiddlewaresMetadata = reflectMiddlewaresMetadata;
|
|
7
|
+
exports.reflectRouteMetadata = reflectRouteMetadata;
|
|
8
|
+
exports.defineMiddlewaresMeta = defineMiddlewaresMeta;
|
|
9
|
+
exports.defineRouteMeta = defineRouteMeta;
|
|
5
10
|
require("reflect-metadata");
|
|
6
11
|
const constants_1 = require("../../constants");
|
|
7
12
|
const generateUniqueId = () => {
|
|
8
13
|
return `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
9
14
|
};
|
|
10
15
|
exports.generateUniqueId = generateUniqueId;
|
|
11
|
-
function
|
|
12
|
-
const data = Reflect.getMetadata(constants_1.
|
|
13
|
-
if (
|
|
14
|
-
['
|
|
15
|
-
if (!data[prop]?.length) {
|
|
16
|
-
data[prop] = [];
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
return data;
|
|
16
|
+
function reflectControllerMeta(target) {
|
|
17
|
+
const data = Reflect.getMetadata(constants_1.DECORATOR.controller, target) ?? {};
|
|
18
|
+
if (!data['controllers']) {
|
|
19
|
+
data['controllers'] = [];
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
23
|
+
function defineControllerMeta(meta, target) {
|
|
24
|
+
const existed = reflectControllerMeta(target);
|
|
25
|
+
const merged = Object.entries(meta).reduce((acc, [key, value]) => {
|
|
26
|
+
if (Array.isArray(acc[key])) {
|
|
27
|
+
acc[key] = acc[key].concat(value);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
acc[key] = value;
|
|
31
|
+
}
|
|
32
|
+
return acc;
|
|
33
|
+
}, existed);
|
|
34
|
+
Reflect.defineMetadata(constants_1.DECORATOR.controller, merged, target);
|
|
35
|
+
}
|
|
36
|
+
function reflectMiddlewaresMetadata(target, propertie) {
|
|
37
|
+
let data;
|
|
38
|
+
if (propertie) {
|
|
39
|
+
data = Reflect.getMetadata(constants_1.DECORATOR.middlewares, target, propertie) ?? {};
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
data = Reflect.getMetadata(constants_1.DECORATOR.middlewares, target) ?? {};
|
|
43
|
+
}
|
|
44
|
+
['middlewares', 'errors', 'guards', 'pipes', 'cors', 'sanitizers', 'interceptors'].forEach((prop) => {
|
|
22
45
|
if (!data[prop]?.length) {
|
|
23
46
|
data[prop] = [];
|
|
24
47
|
}
|
|
25
48
|
});
|
|
26
49
|
return data;
|
|
27
50
|
}
|
|
51
|
+
function reflectRouteMetadata(target, popertie) {
|
|
52
|
+
const data = Reflect.getMetadata(constants_1.DECORATOR.route, target, popertie) ?? {};
|
|
53
|
+
['parameters', 'middlewares'].forEach((prop) => {
|
|
54
|
+
if (!data[prop]?.length) {
|
|
55
|
+
data[prop] = [];
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return data;
|
|
59
|
+
}
|
|
60
|
+
function defineMiddlewaresMeta(meta, target, propertie) {
|
|
61
|
+
const existed = reflectMiddlewaresMetadata(target, propertie);
|
|
62
|
+
const merged = Object.entries(meta).reduce((acc, [key, value]) => {
|
|
63
|
+
if (Array.isArray(acc[key])) {
|
|
64
|
+
acc[key] = acc[key].concat(value);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
acc[key] = value;
|
|
68
|
+
}
|
|
69
|
+
return acc;
|
|
70
|
+
}, existed);
|
|
71
|
+
if (propertie) {
|
|
72
|
+
Reflect.defineMetadata(constants_1.DECORATOR.middlewares, merged, target, propertie);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
Reflect.defineMetadata(constants_1.DECORATOR.middlewares, merged, target);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function defineRouteMeta(meta, target, propertie) {
|
|
79
|
+
const existed = reflectRouteMetadata(target, propertie);
|
|
80
|
+
const merged = Object.entries(meta).reduce((acc, [key, value]) => {
|
|
81
|
+
if (Array.isArray(acc[key])) {
|
|
82
|
+
acc[key] = acc[key].concat(value);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
acc[key] = value;
|
|
86
|
+
}
|
|
87
|
+
return acc;
|
|
88
|
+
}, existed);
|
|
89
|
+
Reflect.defineMetadata(constants_1.DECORATOR.route, merged, target, propertie);
|
|
90
|
+
}
|
|
28
91
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/utils/shared/helpers.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/utils/shared/helpers.ts"],"names":[],"mappings":";;;AAQA,sDAOC;AACD,oDAaC;AAED,gEAiBC;AACD,oDAUC;AAQD,sDAqBC;AAMD,0CAaC;AA3GD,4BAA0B;AAC1B,+CAA4C;AAGrC,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AACvE,CAAC,CAAC;AAFW,QAAA,gBAAgB,oBAE3B;AAEF,SAAgB,qBAAqB,CAAC,MAAc;IAClD,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC,qBAAS,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;IAErE,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;QACzB,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC;IAC3B,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AACD,SAAgB,oBAAoB,CAAC,IAA6B,EAAE,MAAc;IAChF,MAAM,OAAO,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAE9C,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAC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C,CAAC;IACxD,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAC/D,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YAC5B,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACpC,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACnB,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,OAAc,CAAC,CAAC;IAEnB,OAAO,CAAC,cAAc,CAAC,qBAAS,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;AACrE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heliosjs/middlewares",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"description": "Core functionality for Quantum Flow",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"reflect-metadata": "^0.2.2"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@heliosjs/core": "^2.
|
|
33
|
+
"@heliosjs/core": "^2.1.2",
|
|
34
34
|
"typescript": ">=4.0.0"
|
|
35
35
|
}
|
|
36
36
|
}
|
package/dist/helper.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const reflectMeta: (target: object) => void;
|
package/dist/helper.js
DELETED
package/dist/helper.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":";;;AAAO,MAAM,WAAW,GAAG,CAAC,MAAc,EAAE,EAAE,GAAE,CAAC,CAAC;AAArC,QAAA,WAAW,eAA0B"}
|