framework-do-dede 1.0.16 → 1.0.17

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.
@@ -1,5 +1,7 @@
1
1
  export function Auth(middlewareKey) {
2
2
  return function (target, propertyKey) {
3
- Reflect.defineMetadata('auth', middlewareKey, target, propertyKey);
3
+ const metadata = Reflect.getMetadata('auth', target.constructor) || [];
4
+ metadata.push({ propertyKey, middlewareKey });
5
+ Reflect.defineMetadata('auth', metadata, target.constructor);
4
6
  };
5
7
  }
package/dist/index.js CHANGED
@@ -7,10 +7,9 @@ class UseCaseHandler {
7
7
  static load(useCaseClass, request) {
8
8
  const instance = Registry.classLoader(useCaseClass);
9
9
  const context = request;
10
- const prototype = useCaseClass.prototype;
11
- Reflect.ownKeys(prototype).forEach((propertyKey) => {
12
- const middlewareKey = Reflect.getMetadata('auth', prototype, propertyKey);
13
- if (middlewareKey && context?.middlewareData?.[middlewareKey]) {
10
+ const authMetadata = Reflect.getMetadata('auth', useCaseClass) || [];
11
+ authMetadata.forEach(({ propertyKey, middlewareKey }) => {
12
+ if (context?.middlewareData?.[middlewareKey]) {
14
13
  instance[propertyKey] = context.middlewareData[middlewareKey];
15
14
  }
16
15
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "framework-do-dede",
3
- "version": "1.0.16",
3
+ "version": "1.0.17",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",