fragment-ts 1.0.33 → 1.0.34
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/cli/commands/init.command.js +1 -1
- package/dist/core/decorators/exception-filter.decorator.d.ts.map +1 -1
- package/dist/core/decorators/exception-filter.decorator.js +11 -4
- package/dist/core/decorators/exception-filter.decorator.js.map +1 -1
- package/dist/core/decorators/guard.decorator.d.ts.map +1 -1
- package/dist/core/decorators/guard.decorator.js +11 -4
- package/dist/core/decorators/guard.decorator.js.map +1 -1
- package/dist/core/decorators/interceptor.decorator.d.ts.map +1 -1
- package/dist/core/decorators/interceptor.decorator.js +10 -4
- package/dist/core/decorators/interceptor.decorator.js.map +1 -1
- package/dist/core/decorators/middleware.decorator.d.ts.map +1 -1
- package/dist/core/decorators/middleware.decorator.js +8 -4
- package/dist/core/decorators/middleware.decorator.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/commands/init.command.ts +1 -1
- package/src/core/decorators/exception-filter.decorator.ts +29 -6
- package/src/core/decorators/guard.decorator.ts +28 -5
- package/src/core/decorators/interceptor.decorator.ts +32 -6
- package/src/core/decorators/middleware.decorator.ts +30 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exception-filter.decorator.d.ts","sourceRoot":"","sources":["../../../src/core/decorators/exception-filter.decorator.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAgB,uBAAuB,
|
|
1
|
+
{"version":3,"file":"exception-filter.decorator.d.ts","sourceRoot":"","sources":["../../../src/core/decorators/exception-filter.decorator.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,UAAU,GAAG,GACzB,cAAc,GAAG,eAAe,CAiClC"}
|
|
@@ -9,14 +9,21 @@ const metadata_storage_1 = require("../metadata/metadata-storage");
|
|
|
9
9
|
function FragmentExceptionFilter(filterClass) {
|
|
10
10
|
return (target, propertyKey) => {
|
|
11
11
|
if (propertyKey === undefined) {
|
|
12
|
-
|
|
12
|
+
// Class-level
|
|
13
|
+
const existing = Reflect.getMetadata(metadata_keys_1.METADATA_KEYS.USE_FILTERS, target) || [];
|
|
14
|
+
const updated = [...existing, filterClass];
|
|
15
|
+
Reflect.defineMetadata(metadata_keys_1.METADATA_KEYS.USE_FILTERS, updated, target);
|
|
13
16
|
const storage = metadata_storage_1.MetadataStorage.getInstance();
|
|
14
|
-
storage.addClassMetadata?.(target,
|
|
17
|
+
storage.addClassMetadata?.(target, "exceptionFilter", filterClass);
|
|
15
18
|
}
|
|
16
19
|
else {
|
|
17
|
-
|
|
20
|
+
// Method-level
|
|
21
|
+
const existing = Reflect.getMetadata(metadata_keys_1.METADATA_KEYS.USE_FILTERS, target, propertyKey) ||
|
|
22
|
+
[];
|
|
23
|
+
const updated = [...existing, filterClass];
|
|
24
|
+
Reflect.defineMetadata(metadata_keys_1.METADATA_KEYS.USE_FILTERS, updated, target, propertyKey);
|
|
18
25
|
const storage = metadata_storage_1.MetadataStorage.getInstance();
|
|
19
|
-
storage.addMethodMetadata?.(target.constructor, propertyKey.toString(),
|
|
26
|
+
storage.addMethodMetadata?.(target.constructor, propertyKey.toString(), "exceptionFilter", filterClass);
|
|
20
27
|
}
|
|
21
28
|
};
|
|
22
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exception-filter.decorator.js","sourceRoot":"","sources":["../../../src/core/decorators/exception-filter.decorator.ts"],"names":[],"mappings":";;AAOA,
|
|
1
|
+
{"version":3,"file":"exception-filter.decorator.js","sourceRoot":"","sources":["../../../src/core/decorators/exception-filter.decorator.ts"],"names":[],"mappings":";;AAOA,0DAmCC;AAzCD,6DAA0D;AAC1D,mEAA+D;AAE/D;;GAEG;AACH,SAAgB,uBAAuB,CACrC,WAA0B;IAE1B,OAAO,CAAC,MAAW,EAAE,WAA6B,EAAE,EAAE;QACpD,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC9B,cAAc;YACd,MAAM,QAAQ,GACZ,OAAO,CAAC,WAAW,CAAC,6BAAa,CAAC,WAAW,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;YAC/D,MAAM,OAAO,GAAG,CAAC,GAAG,QAAQ,EAAE,WAAW,CAAC,CAAC;YAC3C,OAAO,CAAC,cAAc,CAAC,6BAAa,CAAC,WAAW,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;YAEnE,MAAM,OAAO,GAAG,kCAAe,CAAC,WAAW,EAAE,CAAC;YAC9C,OAAO,CAAC,gBAAgB,EAAE,CAAC,MAAM,EAAE,iBAAiB,EAAE,WAAW,CAAC,CAAC;QACrE,CAAC;aAAM,CAAC;YACN,eAAe;YACf,MAAM,QAAQ,GACZ,OAAO,CAAC,WAAW,CAAC,6BAAa,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,CAAC;gBACnE,EAAE,CAAC;YACL,MAAM,OAAO,GAAG,CAAC,GAAG,QAAQ,EAAE,WAAW,CAAC,CAAC;YAC3C,OAAO,CAAC,cAAc,CACpB,6BAAa,CAAC,WAAW,EACzB,OAAO,EACP,MAAM,EACN,WAAW,CACZ,CAAC;YAEF,MAAM,OAAO,GAAG,kCAAe,CAAC,WAAW,EAAE,CAAC;YAC9C,OAAO,CAAC,iBAAiB,EAAE,CACzB,MAAM,CAAC,WAAW,EAClB,WAAW,CAAC,QAAQ,EAAE,EACtB,iBAAiB,EACjB,WAAW,CACZ,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard.decorator.d.ts","sourceRoot":"","sources":["../../../src/core/decorators/guard.decorator.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAgB,aAAa,
|
|
1
|
+
{"version":3,"file":"guard.decorator.d.ts","sourceRoot":"","sources":["../../../src/core/decorators/guard.decorator.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAgB,aAAa,CAC3B,UAAU,EAAE,UAAU,GAAG,GACxB,cAAc,GAAG,eAAe,CAiClC"}
|
|
@@ -9,14 +9,21 @@ const metadata_storage_1 = require("../metadata/metadata-storage");
|
|
|
9
9
|
function FragmentGuard(guardClass) {
|
|
10
10
|
return (target, propertyKey) => {
|
|
11
11
|
if (propertyKey === undefined) {
|
|
12
|
-
|
|
12
|
+
// Class-level
|
|
13
|
+
const existing = Reflect.getMetadata(metadata_keys_1.METADATA_KEYS.USE_GUARDS, target) || [];
|
|
14
|
+
const updated = [...existing, guardClass];
|
|
15
|
+
Reflect.defineMetadata(metadata_keys_1.METADATA_KEYS.USE_GUARDS, updated, target);
|
|
13
16
|
const storage = metadata_storage_1.MetadataStorage.getInstance();
|
|
14
|
-
storage.addClassMetadata?.(target,
|
|
17
|
+
storage.addClassMetadata?.(target, "guard", guardClass);
|
|
15
18
|
}
|
|
16
19
|
else {
|
|
17
|
-
|
|
20
|
+
// Method-level
|
|
21
|
+
const existing = Reflect.getMetadata(metadata_keys_1.METADATA_KEYS.USE_GUARDS, target, propertyKey) ||
|
|
22
|
+
[];
|
|
23
|
+
const updated = [...existing, guardClass];
|
|
24
|
+
Reflect.defineMetadata(metadata_keys_1.METADATA_KEYS.USE_GUARDS, updated, target, propertyKey);
|
|
18
25
|
const storage = metadata_storage_1.MetadataStorage.getInstance();
|
|
19
|
-
storage.addMethodMetadata?.(target.constructor, propertyKey.toString(),
|
|
26
|
+
storage.addMethodMetadata?.(target.constructor, propertyKey.toString(), "guard", guardClass);
|
|
20
27
|
}
|
|
21
28
|
};
|
|
22
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard.decorator.js","sourceRoot":"","sources":["../../../src/core/decorators/guard.decorator.ts"],"names":[],"mappings":";;AAOA,
|
|
1
|
+
{"version":3,"file":"guard.decorator.js","sourceRoot":"","sources":["../../../src/core/decorators/guard.decorator.ts"],"names":[],"mappings":";;AAOA,sCAmCC;AAzCD,6DAA0D;AAC1D,mEAA+D;AAE/D;;GAEG;AACH,SAAgB,aAAa,CAC3B,UAAyB;IAEzB,OAAO,CAAC,MAAW,EAAE,WAA6B,EAAE,EAAE;QACpD,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC9B,cAAc;YACd,MAAM,QAAQ,GACZ,OAAO,CAAC,WAAW,CAAC,6BAAa,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;YAC9D,MAAM,OAAO,GAAG,CAAC,GAAG,QAAQ,EAAE,UAAU,CAAC,CAAC;YAC1C,OAAO,CAAC,cAAc,CAAC,6BAAa,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;YAElE,MAAM,OAAO,GAAG,kCAAe,CAAC,WAAW,EAAE,CAAC;YAC9C,OAAO,CAAC,gBAAgB,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QAC1D,CAAC;aAAM,CAAC;YACN,eAAe;YACf,MAAM,QAAQ,GACZ,OAAO,CAAC,WAAW,CAAC,6BAAa,CAAC,UAAU,EAAE,MAAM,EAAE,WAAW,CAAC;gBAClE,EAAE,CAAC;YACL,MAAM,OAAO,GAAG,CAAC,GAAG,QAAQ,EAAE,UAAU,CAAC,CAAC;YAC1C,OAAO,CAAC,cAAc,CACpB,6BAAa,CAAC,UAAU,EACxB,OAAO,EACP,MAAM,EACN,WAAW,CACZ,CAAC;YAEF,MAAM,OAAO,GAAG,kCAAe,CAAC,WAAW,EAAE,CAAC;YAC9C,OAAO,CAAC,iBAAiB,EAAE,CACzB,MAAM,CAAC,WAAW,EAClB,WAAW,CAAC,QAAQ,EAAE,EACtB,OAAO,EACP,UAAU,CACX,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interceptor.decorator.d.ts","sourceRoot":"","sources":["../../../src/core/decorators/interceptor.decorator.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAgB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"interceptor.decorator.d.ts","sourceRoot":"","sources":["../../../src/core/decorators/interceptor.decorator.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,gBAAgB,EAAE,UAAU,GAAG,GAC9B,cAAc,GAAG,eAAe,CAoClC"}
|
|
@@ -9,14 +9,20 @@ const metadata_storage_1 = require("../metadata/metadata-storage");
|
|
|
9
9
|
function FragmentInterceptor(interceptorClass) {
|
|
10
10
|
return (target, propertyKey) => {
|
|
11
11
|
if (propertyKey === undefined) {
|
|
12
|
-
|
|
12
|
+
// Class-level
|
|
13
|
+
const existing = Reflect.getMetadata(metadata_keys_1.METADATA_KEYS.USE_INTERCEPTORS, target) || [];
|
|
14
|
+
const updated = [...existing, interceptorClass];
|
|
15
|
+
Reflect.defineMetadata(metadata_keys_1.METADATA_KEYS.USE_INTERCEPTORS, updated, target);
|
|
13
16
|
const storage = metadata_storage_1.MetadataStorage.getInstance();
|
|
14
|
-
storage.addClassMetadata?.(target,
|
|
17
|
+
storage.addClassMetadata?.(target, "interceptor", interceptorClass);
|
|
15
18
|
}
|
|
16
19
|
else {
|
|
17
|
-
|
|
20
|
+
// Method-level
|
|
21
|
+
const existing = Reflect.getMetadata(metadata_keys_1.METADATA_KEYS.USE_INTERCEPTORS, target, propertyKey) || [];
|
|
22
|
+
const updated = [...existing, interceptorClass];
|
|
23
|
+
Reflect.defineMetadata(metadata_keys_1.METADATA_KEYS.USE_INTERCEPTORS, updated, target, propertyKey);
|
|
18
24
|
const storage = metadata_storage_1.MetadataStorage.getInstance();
|
|
19
|
-
storage.addMethodMetadata?.(target.constructor, propertyKey.toString(),
|
|
25
|
+
storage.addMethodMetadata?.(target.constructor, propertyKey.toString(), "interceptor", interceptorClass);
|
|
20
26
|
}
|
|
21
27
|
};
|
|
22
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interceptor.decorator.js","sourceRoot":"","sources":["../../../src/core/decorators/interceptor.decorator.ts"],"names":[],"mappings":";;AAOA,
|
|
1
|
+
{"version":3,"file":"interceptor.decorator.js","sourceRoot":"","sources":["../../../src/core/decorators/interceptor.decorator.ts"],"names":[],"mappings":";;AAOA,kDAsCC;AA5CD,6DAA0D;AAC1D,mEAA+D;AAE/D;;GAEG;AACH,SAAgB,mBAAmB,CACjC,gBAA+B;IAE/B,OAAO,CAAC,MAAW,EAAE,WAA6B,EAAE,EAAE;QACpD,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC9B,cAAc;YACd,MAAM,QAAQ,GACZ,OAAO,CAAC,WAAW,CAAC,6BAAa,CAAC,gBAAgB,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;YACpE,MAAM,OAAO,GAAG,CAAC,GAAG,QAAQ,EAAE,gBAAgB,CAAC,CAAC;YAChD,OAAO,CAAC,cAAc,CAAC,6BAAa,CAAC,gBAAgB,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;YAExE,MAAM,OAAO,GAAG,kCAAe,CAAC,WAAW,EAAE,CAAC;YAC9C,OAAO,CAAC,gBAAgB,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,gBAAgB,CAAC,CAAC;QACtE,CAAC;aAAM,CAAC;YACN,eAAe;YACf,MAAM,QAAQ,GACZ,OAAO,CAAC,WAAW,CACjB,6BAAa,CAAC,gBAAgB,EAC9B,MAAM,EACN,WAAW,CACZ,IAAI,EAAE,CAAC;YACV,MAAM,OAAO,GAAG,CAAC,GAAG,QAAQ,EAAE,gBAAgB,CAAC,CAAC;YAChD,OAAO,CAAC,cAAc,CACpB,6BAAa,CAAC,gBAAgB,EAC9B,OAAO,EACP,MAAM,EACN,WAAW,CACZ,CAAC;YAEF,MAAM,OAAO,GAAG,kCAAe,CAAC,WAAW,EAAE,CAAC;YAC9C,OAAO,CAAC,iBAAiB,EAAE,CACzB,MAAM,CAAC,WAAW,EAClB,WAAW,CAAC,QAAQ,EAAE,EACtB,aAAa,EACb,gBAAgB,CACjB,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.decorator.d.ts","sourceRoot":"","sources":["../../../src/core/decorators/middleware.decorator.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,wBAAgB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"middleware.decorator.d.ts","sourceRoot":"","sources":["../../../src/core/decorators/middleware.decorator.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,eAAe,EAAE,UAAU,GAAG,GAC7B,cAAc,GAAG,eAAe,CAoClC"}
|
|
@@ -13,15 +13,19 @@ function FragmentMiddleware(middlewareClass) {
|
|
|
13
13
|
return (target, propertyKey) => {
|
|
14
14
|
if (propertyKey === undefined) {
|
|
15
15
|
// Class-level
|
|
16
|
-
Reflect.
|
|
16
|
+
const existing = Reflect.getMetadata(metadata_keys_1.METADATA_KEYS.USE_MIDDLEWARE, target) || [];
|
|
17
|
+
const updated = [...existing, middlewareClass];
|
|
18
|
+
Reflect.defineMetadata(metadata_keys_1.METADATA_KEYS.USE_MIDDLEWARE, updated, target);
|
|
17
19
|
const storage = metadata_storage_1.MetadataStorage.getInstance();
|
|
18
|
-
storage.addClassMetadata?.(target,
|
|
20
|
+
storage.addClassMetadata?.(target, "middleware", middlewareClass);
|
|
19
21
|
}
|
|
20
22
|
else {
|
|
21
23
|
// Method-level
|
|
22
|
-
Reflect.
|
|
24
|
+
const existing = Reflect.getMetadata(metadata_keys_1.METADATA_KEYS.USE_MIDDLEWARE, target, propertyKey) || [];
|
|
25
|
+
const updated = [...existing, middlewareClass];
|
|
26
|
+
Reflect.defineMetadata(metadata_keys_1.METADATA_KEYS.USE_MIDDLEWARE, updated, target, propertyKey);
|
|
23
27
|
const storage = metadata_storage_1.MetadataStorage.getInstance();
|
|
24
|
-
storage.addMethodMetadata?.(target.constructor, propertyKey.toString(),
|
|
28
|
+
storage.addMethodMetadata?.(target.constructor, propertyKey.toString(), "middleware", middlewareClass);
|
|
25
29
|
}
|
|
26
30
|
};
|
|
27
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.decorator.js","sourceRoot":"","sources":["../../../src/core/decorators/middleware.decorator.ts"],"names":[],"mappings":";;AAUA,
|
|
1
|
+
{"version":3,"file":"middleware.decorator.js","sourceRoot":"","sources":["../../../src/core/decorators/middleware.decorator.ts"],"names":[],"mappings":";;AAUA,gDAsCC;AA/CD,6DAA0D;AAC1D,mEAA+D;AAE/D;;;;;GAKG;AACH,SAAgB,kBAAkB,CAChC,eAA8B;IAE9B,OAAO,CAAC,MAAW,EAAE,WAA6B,EAAE,EAAE;QACpD,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC9B,cAAc;YACd,MAAM,QAAQ,GACZ,OAAO,CAAC,WAAW,CAAC,6BAAa,CAAC,cAAc,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;YAClE,MAAM,OAAO,GAAG,CAAC,GAAG,QAAQ,EAAE,eAAe,CAAC,CAAC;YAC/C,OAAO,CAAC,cAAc,CAAC,6BAAa,CAAC,cAAc,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;YAEtE,MAAM,OAAO,GAAG,kCAAe,CAAC,WAAW,EAAE,CAAC;YAC9C,OAAO,CAAC,gBAAgB,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,eAAe,CAAC,CAAC;QACpE,CAAC;aAAM,CAAC;YACN,eAAe;YACf,MAAM,QAAQ,GACZ,OAAO,CAAC,WAAW,CACjB,6BAAa,CAAC,cAAc,EAC5B,MAAM,EACN,WAAW,CACZ,IAAI,EAAE,CAAC;YACV,MAAM,OAAO,GAAG,CAAC,GAAG,QAAQ,EAAE,eAAe,CAAC,CAAC;YAC/C,OAAO,CAAC,cAAc,CACpB,6BAAa,CAAC,cAAc,EAC5B,OAAO,EACP,MAAM,EACN,WAAW,CACZ,CAAC;YAEF,MAAM,OAAO,GAAG,kCAAe,CAAC,WAAW,EAAE,CAAC;YAC9C,OAAO,CAAC,iBAAiB,EAAE,CACzB,MAAM,CAAC,WAAW,EAClB,WAAW,CAAC,QAAQ,EAAE,EACtB,YAAY,EACZ,eAAe,CAChB,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -5,16 +5,39 @@ import { MetadataStorage } from "../metadata/metadata-storage";
|
|
|
5
5
|
/**
|
|
6
6
|
* @ExceptionFilter - Handle exceptions globally or per controller/method
|
|
7
7
|
*/
|
|
8
|
-
export function FragmentExceptionFilter(
|
|
8
|
+
export function FragmentExceptionFilter(
|
|
9
|
+
filterClass: new () => any,
|
|
10
|
+
): ClassDecorator & MethodDecorator {
|
|
9
11
|
return (target: any, propertyKey?: string | symbol) => {
|
|
10
12
|
if (propertyKey === undefined) {
|
|
11
|
-
|
|
13
|
+
// Class-level
|
|
14
|
+
const existing =
|
|
15
|
+
Reflect.getMetadata(METADATA_KEYS.USE_FILTERS, target) || [];
|
|
16
|
+
const updated = [...existing, filterClass];
|
|
17
|
+
Reflect.defineMetadata(METADATA_KEYS.USE_FILTERS, updated, target);
|
|
18
|
+
|
|
12
19
|
const storage = MetadataStorage.getInstance();
|
|
13
|
-
storage.addClassMetadata?.(target,
|
|
20
|
+
storage.addClassMetadata?.(target, "exceptionFilter", filterClass);
|
|
14
21
|
} else {
|
|
15
|
-
|
|
22
|
+
// Method-level
|
|
23
|
+
const existing =
|
|
24
|
+
Reflect.getMetadata(METADATA_KEYS.USE_FILTERS, target, propertyKey) ||
|
|
25
|
+
[];
|
|
26
|
+
const updated = [...existing, filterClass];
|
|
27
|
+
Reflect.defineMetadata(
|
|
28
|
+
METADATA_KEYS.USE_FILTERS,
|
|
29
|
+
updated,
|
|
30
|
+
target,
|
|
31
|
+
propertyKey,
|
|
32
|
+
);
|
|
33
|
+
|
|
16
34
|
const storage = MetadataStorage.getInstance();
|
|
17
|
-
storage.addMethodMetadata?.(
|
|
35
|
+
storage.addMethodMetadata?.(
|
|
36
|
+
target.constructor,
|
|
37
|
+
propertyKey.toString(),
|
|
38
|
+
"exceptionFilter",
|
|
39
|
+
filterClass,
|
|
40
|
+
);
|
|
18
41
|
}
|
|
19
42
|
};
|
|
20
|
-
}
|
|
43
|
+
}
|
|
@@ -5,16 +5,39 @@ import { MetadataStorage } from "../metadata/metadata-storage";
|
|
|
5
5
|
/**
|
|
6
6
|
* @Guard - Apply authorization/activation guard
|
|
7
7
|
*/
|
|
8
|
-
export function FragmentGuard(
|
|
8
|
+
export function FragmentGuard(
|
|
9
|
+
guardClass: new () => any,
|
|
10
|
+
): ClassDecorator & MethodDecorator {
|
|
9
11
|
return (target: any, propertyKey?: string | symbol) => {
|
|
10
12
|
if (propertyKey === undefined) {
|
|
11
|
-
|
|
13
|
+
// Class-level
|
|
14
|
+
const existing =
|
|
15
|
+
Reflect.getMetadata(METADATA_KEYS.USE_GUARDS, target) || [];
|
|
16
|
+
const updated = [...existing, guardClass];
|
|
17
|
+
Reflect.defineMetadata(METADATA_KEYS.USE_GUARDS, updated, target);
|
|
18
|
+
|
|
12
19
|
const storage = MetadataStorage.getInstance();
|
|
13
|
-
storage.addClassMetadata?.(target,
|
|
20
|
+
storage.addClassMetadata?.(target, "guard", guardClass);
|
|
14
21
|
} else {
|
|
15
|
-
|
|
22
|
+
// Method-level
|
|
23
|
+
const existing =
|
|
24
|
+
Reflect.getMetadata(METADATA_KEYS.USE_GUARDS, target, propertyKey) ||
|
|
25
|
+
[];
|
|
26
|
+
const updated = [...existing, guardClass];
|
|
27
|
+
Reflect.defineMetadata(
|
|
28
|
+
METADATA_KEYS.USE_GUARDS,
|
|
29
|
+
updated,
|
|
30
|
+
target,
|
|
31
|
+
propertyKey,
|
|
32
|
+
);
|
|
33
|
+
|
|
16
34
|
const storage = MetadataStorage.getInstance();
|
|
17
|
-
storage.addMethodMetadata?.(
|
|
35
|
+
storage.addMethodMetadata?.(
|
|
36
|
+
target.constructor,
|
|
37
|
+
propertyKey.toString(),
|
|
38
|
+
"guard",
|
|
39
|
+
guardClass,
|
|
40
|
+
);
|
|
18
41
|
}
|
|
19
42
|
};
|
|
20
43
|
}
|
|
@@ -5,16 +5,42 @@ import { MetadataStorage } from "../metadata/metadata-storage";
|
|
|
5
5
|
/**
|
|
6
6
|
* @Interceptor - Intercept and transform request/response
|
|
7
7
|
*/
|
|
8
|
-
export function FragmentInterceptor(
|
|
8
|
+
export function FragmentInterceptor(
|
|
9
|
+
interceptorClass: new () => any,
|
|
10
|
+
): ClassDecorator & MethodDecorator {
|
|
9
11
|
return (target: any, propertyKey?: string | symbol) => {
|
|
10
12
|
if (propertyKey === undefined) {
|
|
11
|
-
|
|
13
|
+
// Class-level
|
|
14
|
+
const existing =
|
|
15
|
+
Reflect.getMetadata(METADATA_KEYS.USE_INTERCEPTORS, target) || [];
|
|
16
|
+
const updated = [...existing, interceptorClass];
|
|
17
|
+
Reflect.defineMetadata(METADATA_KEYS.USE_INTERCEPTORS, updated, target);
|
|
18
|
+
|
|
12
19
|
const storage = MetadataStorage.getInstance();
|
|
13
|
-
storage.addClassMetadata?.(target,
|
|
20
|
+
storage.addClassMetadata?.(target, "interceptor", interceptorClass);
|
|
14
21
|
} else {
|
|
15
|
-
|
|
22
|
+
// Method-level
|
|
23
|
+
const existing =
|
|
24
|
+
Reflect.getMetadata(
|
|
25
|
+
METADATA_KEYS.USE_INTERCEPTORS,
|
|
26
|
+
target,
|
|
27
|
+
propertyKey,
|
|
28
|
+
) || [];
|
|
29
|
+
const updated = [...existing, interceptorClass];
|
|
30
|
+
Reflect.defineMetadata(
|
|
31
|
+
METADATA_KEYS.USE_INTERCEPTORS,
|
|
32
|
+
updated,
|
|
33
|
+
target,
|
|
34
|
+
propertyKey,
|
|
35
|
+
);
|
|
36
|
+
|
|
16
37
|
const storage = MetadataStorage.getInstance();
|
|
17
|
-
storage.addMethodMetadata?.(
|
|
38
|
+
storage.addMethodMetadata?.(
|
|
39
|
+
target.constructor,
|
|
40
|
+
propertyKey.toString(),
|
|
41
|
+
"interceptor",
|
|
42
|
+
interceptorClass,
|
|
43
|
+
);
|
|
18
44
|
}
|
|
19
45
|
};
|
|
20
|
-
}
|
|
46
|
+
}
|
|
@@ -8,18 +8,42 @@ import { MetadataStorage } from "../metadata/metadata-storage";
|
|
|
8
8
|
* @Middleware(AuthMiddleware) class MyController { }
|
|
9
9
|
* @Middleware(AuthMiddleware) @Get('/') handler() { }
|
|
10
10
|
*/
|
|
11
|
-
export function FragmentMiddleware(
|
|
11
|
+
export function FragmentMiddleware(
|
|
12
|
+
middlewareClass: new () => any,
|
|
13
|
+
): ClassDecorator & MethodDecorator {
|
|
12
14
|
return (target: any, propertyKey?: string | symbol) => {
|
|
13
15
|
if (propertyKey === undefined) {
|
|
14
16
|
// Class-level
|
|
15
|
-
|
|
17
|
+
const existing =
|
|
18
|
+
Reflect.getMetadata(METADATA_KEYS.USE_MIDDLEWARE, target) || [];
|
|
19
|
+
const updated = [...existing, middlewareClass];
|
|
20
|
+
Reflect.defineMetadata(METADATA_KEYS.USE_MIDDLEWARE, updated, target);
|
|
21
|
+
|
|
16
22
|
const storage = MetadataStorage.getInstance();
|
|
17
|
-
storage.addClassMetadata?.(target,
|
|
23
|
+
storage.addClassMetadata?.(target, "middleware", middlewareClass);
|
|
18
24
|
} else {
|
|
19
25
|
// Method-level
|
|
20
|
-
|
|
26
|
+
const existing =
|
|
27
|
+
Reflect.getMetadata(
|
|
28
|
+
METADATA_KEYS.USE_MIDDLEWARE,
|
|
29
|
+
target,
|
|
30
|
+
propertyKey,
|
|
31
|
+
) || [];
|
|
32
|
+
const updated = [...existing, middlewareClass];
|
|
33
|
+
Reflect.defineMetadata(
|
|
34
|
+
METADATA_KEYS.USE_MIDDLEWARE,
|
|
35
|
+
updated,
|
|
36
|
+
target,
|
|
37
|
+
propertyKey,
|
|
38
|
+
);
|
|
39
|
+
|
|
21
40
|
const storage = MetadataStorage.getInstance();
|
|
22
|
-
storage.addMethodMetadata?.(
|
|
41
|
+
storage.addMethodMetadata?.(
|
|
42
|
+
target.constructor,
|
|
43
|
+
propertyKey.toString(),
|
|
44
|
+
"middleware",
|
|
45
|
+
middlewareClass,
|
|
46
|
+
);
|
|
23
47
|
}
|
|
24
48
|
};
|
|
25
|
-
}
|
|
49
|
+
}
|